android native development recyclerview


1, activity_recyclerview_test.xml file

<?xml version="1.0" encoding="utf-8"?>

<ImageView
    android:id="@+id/iv_icon"
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:src="@drawable/img_test"/>
<LinearLayout
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:layout_marginLeft="10dp"
    android:orientation="vertical">
    <TextView
        android:id="@+id/tv_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@android:color/holo_blue_dark"
        android:text="full name"
        android:textSize="20sp"/>

    <TextView
        android:id="@+id/tv_introduces"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@android:color/holo_blue_dark"
        android:text="mobile phone"/>

</LinearLayout>

2, activity_recycler.xml file

<?xml version="1.0" encoding="utf-8"?>

<androidx.recyclerview.widget.RecyclerView
    android:id="@+id/rec"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

3, Recelerviewactivity Java file code

package com.example;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.demo.R;

public class RecylerViewActivity extends AppCompatActivity {
private RecyclerView mRecyclerView;
private HomeAdapter mAdapter;
private String[] names = {"small sample", "small red", "small yellow"};
private int[] icons = {R.mipmap.a,R.mipmap.b,R.mipmap.c};
Private string [] introductions = {"Xiao Hong is a diligent person", "Xiao Hong loves cleanliness very much", "Xiao Huang is very lazy"};

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_recycler);
    mRecyclerView = findViewById(R.id.rec);
    //Set layout mode
    mRecyclerView.setLayoutManager(new LinearLayoutManager(RecylerViewActivity.this));
    mAdapter = new HomeAdapter();
    mRecyclerView.setAdapter(mAdapter);
}

class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.MyViewHolder>{


    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        MyViewHolder holder = new MyViewHolder(LayoutInflater.from(RecylerViewActivity.this).inflate(R.layout.activity_recyclerview_test,parent,false));
        return holder;
    }

    @Override
    //Bind data to the control of cell layout
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        holder.tv_name.setText(names[position]);
        holder.tv_introduces.setText(introduces[position]);
        holder.iv_icon.setImageResource(icons[position]);
    }

    @Override
    public int getItemCount() {
        return names.length;
    }

    class MyViewHolder extends RecyclerView.ViewHolder{
        TextView tv_name;
        TextView tv_introduces;
        ImageView iv_icon;

        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            tv_name = itemView.findViewById(R.id.tv_name);
            tv_introduces = itemView.findViewById(R.id.tv_introduces);
            iv_icon = itemView.findViewById(R.id.iv_icon);

        }
    }
}

}

Welcome to the Markdown editor

Hello! This is the first time you have used the welcome page displayed by the Markdown editor. If you want to learn how to use the Markdown editor, you can read this article carefully to understand the basic syntax of Markdown.

New changes

We have expanded some functions and syntax support for the Markdown editor. In addition to the standard Markdown editor functions, we have added the following new functions to help you blog with it:

  1. The new interface design will bring a new writing experience;
  2. Set your favorite code highlight style in the creation center, and Markdown will display the selected highlight style of code slice display;
  3. The picture drag function is added. You can drag local pictures directly to the editing area for direct display;
  4. New KaTeX mathematical formula grammar;
  5. Added mermaid syntax supporting Gantt chart 1 Function;
  6. The function of multi screen editing Markdown article is added;
  7. The focus writing mode, preview mode, concise writing mode, left and right area synchronous wheel setting and other functions are added. The function button is located in the middle of the editing area and preview area;
  8. Added check list function.

Function shortcut

Undo: Ctrl/Command + Z
Redo: Ctrl/Command + Y
Bold: Ctrl/Command + B
Italic: Ctrl/Command + I
Title: Ctrl/Command + Shift + H
Unordered list: Ctrl/Command + Shift + U
Ordered list: Ctrl/Command + Shift + O
Checklist: Ctrl/Command + Shift + C
Insert code: Ctrl/Command + Shift + K
Insert link: Ctrl/Command + Shift + L
Insert picture: Ctrl/Command + Shift + G
Find: Ctrl/Command + F
Replace: Ctrl/Command + G

Creating a reasonable title is helpful to the generation of the directory

Directly input once #, and press space to generate level 1 title.
After entering twice #, and pressing space, a level 2 title will be generated.
By analogy, we support level 6 titles. It helps to generate a perfect directory after using TOC syntax.

How to change the style of text

Emphasize text emphasize text

Bold text bold text

Tag text

Delete text

Reference text

H2O is a liquid.

The result of 210 operation is 1024

Insert links and pictures

Link: link.

Picture:

Pictures with dimensions:

Centered picture:

Centered and sized picture:

Of course, in order to make users more convenient, we have added the image drag function.

How to insert a beautiful piece of code

go Blog settings Page, select a code slice highlighting style you like, and the same highlighted code slice is shown below

// An highlighted block
var foo = 'bar';

Generate a list that suits you

  • project
    • project
      • project
  1. Item 1
  2. Item 2
  3. Item 3
  • Plan task
  • Complete the task

Create a table

A simple table is created as follows:

project Value
computer $1600
mobile phone $12
catheter $1

The setting content is centered, left and right

Use: ---------: Center
Use: --------- left
Usage -----------: right

First column Second column Third column
First column text centered The text in the second column is on the right The text in the third column is left

SmartyPants

SmartyPants converts ASCII punctuation characters into "smart" printed punctuation HTML entities. For example:

TYPE ASCII HTML
Single backticks 'Isn't this fun?' 'Isn't this fun?'
Quotes "Isn't this fun?" "Isn't this fun?"
Dashes -- is en-dash, --- is em-dash – is en-dash, — is em-dash

Create a custom list

Markdown Text-to- HTML conversion tool Authors John Luke

How to create a footnote

A text with footnotes. 2

Comments are also essential

Markdown converts text to HTML.

KaTeX mathematical formula

You can render LaTeX mathematical expressions using KaTeX:

Gamma formula display Γ ( n ) = ( n − 1 ) ! ∀ n ∈ N \Gamma(n) = (n-1)!\quad\forall n\in\mathbb N Γ (n)=(n−1)! ∀ N ∈ N is through Euler integral

Γ ( z ) = ∫ 0 ∞ t z − 1 e − t d t   . \Gamma(z) = \int_0^\infty t^{z-1}e^{-t}dt\,. Γ(z)=∫0∞​tz−1e−tdt.

You can find more information about LaTeX mathematical expressions here.

New Gantt chart function to enrich your articles

  • For Gantt chart syntax, refer to here,

UML diagram

UML diagrams can be used for rendering. Mermaid For example, a sequence diagram is generated as follows:

This will produce a flowchart.:

  • For Mermaid syntax, refer to here,

FLowchart

We will still support the flowchart of flowchart:

  • For Flowchart syntax, refer to here.

Export and import

export

If you want to try this editor, you can edit it at will in this article. When you have finished writing an article, find the article export in the upper toolbar and generate one md file or html file for local saving.

Import

If you want to load an article you have written md file, you can select the import function in the upper toolbar to import the file with the corresponding extension,
Continue your creation.

  1. mermaid syntax description ↩︎

  2. Explanation of footnotes ↩︎

Posted by pliant on Tue, 03 May 2022 00:11:57 +0300