Writing in the front

As I am a beginner, I write this blog to summarize the knowledge points I have learned and lay a good foundation for the future

Any questions about code and presentation are welcome in the comments section

I am learning about the Fragment and ListView in Android. I want to imitate the function of QQ interface according to the teacher’s requirement

  • There is a login screen
    • Incorrect password Prompt Incorrect password
    • If the account password is blank, the user cannot be blank
    • Login succeeded A message is displayed indicating that the login succeeded
    • You can remember the account and password
  • There are three interfaces you can click the bottom button to switch pages
    • Implementation of the selected and unselected state of the button is different
    • Contact screen
    • Information interface
    • State interface
  • Message sending function
    • Click any message in the message interface to enter the message sending interface
    • You can click the send button to display the input text on the screen

Tip: I use the IDE development environment is Android Studio API 30

Directory Structure Overview

Files in RES

1. Login page

  • The layout file of the login page

activity_main.xml

The ICONS used can be found in the Alibaba icon network iconfont- Alibaba vector icon library


      
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:orientation="vertical"
        tools:ignore="UselessParent">
        <TextView
            android:drawableLeft="@drawable/qq"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="50dp"
            android:layout_marginLeft="120dp"
            android:gravity="center"
            android:text="QQ"
            android:textColor="# 000000"
            android:textSize="35sp"
            app:drawableStartCompat="@drawable/qq"
            android:drawableStart="@drawable/qq"
            tools:ignore="UseCompatTextViewDrawableXml"
            android:layout_marginStart="120dp">
        </TextView>
        <EditText
            android:id="@+id/userNameEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="100dp"
            android:hint="Please enter user name/account number/mobile phone number"
            android:inputType="text"
            android:padding="5dp">
        </EditText>
        <EditText
            android:id="@+id/passwordEditText"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="40dp"
            android:hint="Please enter your password"
            android:inputType="textPassword"
            android:padding="5dp">
        </EditText>
        <ImageButton
            android:id="@+id/loginButton"
            android:layout_marginTop="60dp"
            android:layout_gravity="center"
            android:layout_width="60dp"
            android:layout_height="60dp"
            android:src="@drawable/login"
            android:background="#fff">
        </ImageButton>
    </LinearLayout>

</RelativeLayout>
Copy the code

The corresponding MainActivity

  • The judgment is based on the if statement to determine whether the user typed and correctly
  • Prompted byToastThe way to prompt
package com.czie.qq;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    private Context context;
    private EditText userNameEditText, passwordEditText;
    private ImageButton loginButton;
    private ShareHelper shareHelper;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        context=this;
        shareHelper=new ShareHelper(context);
        initview();
    }

    private void initview(a) {
        userNameEditText = findViewById(R.id.userNameEditText);
        passwordEditText = findViewById(R.id.passwordEditText);
        loginButton = findViewById(R.id.loginButton);
        loginButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // Process the login page
                String username = userNameEditText.getText().toString();
                String password = passwordEditText.getText().toString();
                if (username.length() > 0) {
                    if (username.equals("zk")) {
                        if (password.length() > 0) {
                            if (password.equals("123")) {
                                // Save the account and password
                                shareHelper.save("username",username);
                                shareHelper.save("password",password);
                                startActivity(new Intent(MainActivity.this, HomeActivity.class));
                                Toast.makeText(MainActivity.this."Login successful", Toast.LENGTH_SHORT).show();
                            } else {
                                Toast.makeText(MainActivity.this."Incorrect password", Toast.LENGTH_LONG).show(); }}else {
                            Toast.makeText(MainActivity.this."Please fill in your password.",Toast.LENGTH_LONG).show(); }}else {
                        Toast.makeText(MainActivity.this."Incorrect username",Toast.LENGTH_LONG).show(); }}else {
                    Toast.makeText(MainActivity.this."Please fill in user name",Toast.LENGTH_LONG).show(); }}}); }@Override
    protected void onStart(a) {
        super.onStart();
        userNameEditText.setText(shareHelper.read("username"));
        passwordEditText.setText(shareHelper.read("password")); }}Copy the code

2. Remember passwords

  • After the first successful login, the user name and password will be remembered after the next login

We use SharedPreferences for this feature

What is SharedPreferences

  • SharedPreferences SharedPreferences is a lightweight storage class used to store the common configuration of an Application. It provides string, Set, int, Long, float, and Boolean data types. The final data is stored as XML. In the application usually do some simple data persistent cache.
package com.czie.qq;

import android.content.Context;
import android.content.SharedPreferences;

public class ShareHelper {
    // Two functions save, read
    Context context;

    public ShareHelper(a) {}public ShareHelper(Context context) {
        this.context = context;
    }

    / / save
    public void save(String key, String value) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("iot1921", Context.MODE_PRIVATE);
        // Create an input value
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(key, value);
        editor.commit();
    }

    // Read data
    public String read(String key) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("iot1921", Context.MODE_PRIVATE);
        return sharedPreferences.getString(key, ""); }}Copy the code

Matters needing attention:

  • Remember to submit the input value, editor.com MIT ();
  • inMainACtivityRemember to use shareHelper. read in the OnStart method to pass in the values you need to remember!

Preview the results!

3. The Fragment page is displayed

There are three fragments, and three Fragment layouts are required

  • Start by creating the toggle XML for the three buttons

message.xml


      
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/message_on" android:state_selected="true"/>
    <item android:drawable="@drawable/message_off" android:state_selected="false"/>
</selector>
Copy the code

people.xml


      
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/people_on" android:state_selected="true"/>
    <item android:drawable="@drawable/people_off" android:state_selected="false"/>
</selector>
Copy the code

statue.xml


      
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/statue_on" android:state_selected="true"/>
    <item android:drawable="@drawable/statue_off" android:state_selected="false"/>
</selector>
Copy the code

Then use it in the layout

activity_home.xml

The layout of this interface can be played at will, I do relatively simple, sorry

  • threeImageViewAnd 1FrameLayout
  • ImageViewBind click events separately

      
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <ImageView
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:src="@drawable/basketball">
        </ImageView>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:text="Upcoming">
        </TextView>
        
        <TextView
            android:layout_width="50dp"
            android:layout_marginLeft="250dp"
            android:layout_height="match_parent"
            android:text="+ -"
            android:textSize="25sp">
        </TextView>
    </LinearLayout>

    <FrameLayout
        android:layout_marginTop="10dp"
        android:id="@+id/frameLayout"
        android:layout_width="match_parent"
        android:layout_height="550dp">
    </FrameLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:orientation="horizontal">
    <ImageView
        android:id="@+id/messageImageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="60dp"
        android:background="@drawable/message"
        android:layout_weight="1"
        android:layout_marginStart="0dp">
    </ImageView>

    <ImageView
        android:id="@+id/peopleImageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="150dp"
        android:background="@drawable/people"
        android:layout_weight="1"
        android:layout_marginStart="150dp"
        tools:ignore="ContentDescription">
    </ImageView>

        <ImageView
            android:id="@+id/statueImageView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="170dp"
            android:background="@drawable/statue"
            android:layout_weight="1"
            android:layout_marginStart="170dp"
            tools:ignore="ContentDescription">
        </ImageView>
    </LinearLayout>
</LinearLayout>
Copy the code

3.1 Writing Fragement interface

item_listview.xml


      
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/backgrounds">

    <ListView
        android:id="@+id/messagelistView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </ListView>

</LinearLayout>
Copy the code

fragment_message.xml


      
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/backgrounds">

    <ListView
        android:id="@+id/messagelistView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </ListView>

</LinearLayout>
Copy the code

fragment_people.xml


      
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="30sp"
        android:textColor="# 000000"
        android:text="This is the contacts page."
        tools:ignore="MissingConstraints">
    </TextView>

</LinearLayout>
Copy the code

fragment_statue.xml


      
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="30sp"
        android:textColor="# 000000"
        android:text="This is a dynamic page"
        tools:ignore="MissingConstraints">
    </TextView>

</LinearLayout>
Copy the code

How to load the Fragment layout in FrameLayout

We also need to create the Fragment for the layout

Each Fragment specifies the layout to load and the method to call

OnCreateView () : Calls back each time the Fragment’s View component is created or drawn. The Fragment will display the View component returned by the method. OnActivityCreated () : This method is called back when the Activity in which the Fragment is created has been started.

The implementation is required in this file

  • Click to enter the chat interface
  • Can send messages displayed on the screen

We store the Map in the List collection

The Key stored in the Map is the created Names array, and the Value is the Images array

Load fragment_message by creating a SimpleAdapter object

So these are the three key lines of code

// Which layout screen is loaded in
messagelistView= getActivity().findViewById(R.id.messagelistView);
// Parameters in the adapter
R.layout. item_listView new String[]{"Name","Image"} String array new Int [] {R.i d.N ameTextView, R.i d.I mageView} int array for id * /
        simpleAdapter=new SimpleAdapter(context,dataList,R.layout.item_listview,
                new String[]{"Name"."Image"},
                new int[]{R.id.NameTextView,R.id.ImageView});
// Load the adapter
        messagelistView.setAdapter(simpleAdapter);
Copy the code

A method to getData getData()

 //list retrieves data
    public void getData(a){
        // Add the data from the traversal group to the list
        for (int i = 0; i < Names.length; i++) {
            // Create a map to store the data in the array
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("Name",Names[i]);
            map.put("Image",Images[i]); dataList.add(map); }}Copy the code

MessageFragment

package com.czie.qq;

import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;

import androidx.annotation.Nullable;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MessageFragment extends Fragment {


    private Context context;
    private ListView messagelistView;


    List<Map<String,Object>> dataList=new ArrayList<Map<String,Object>>();
    String [] Names={"Number one"."2"."3"."4"."V"."6"."7"};
    int[] Images={R.mipmap.kaochang,R.mipmap.kaojitui,R.mipmap.kaojichi,R.mipmap.kaoqiezi,R.mipmap.kaolajiao,R.mipmap.kaojinzhengu  ,R.mipmap.kaonanguabing};// Create the SimpleAdapter object
    private SimpleAdapter simpleAdapter;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_message,container,false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        context=getActivity();
        initView();
    }
    private void initView(a) {
        messagelistView= getActivity().findViewById(R.id.messagelistView);
        getData();
        simpleAdapter=new SimpleAdapter(context,dataList,R.layout.item_listview,
                new String[]{"Name"."Image"},
                new int[]{R.id.NameTextView,R.id.ImageView});
        messagelistView.setAdapter(simpleAdapter);
        // The listView item clicks to listen for events
        messagelistView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<? > adapterView, View view,int i, long l) {
                // Get the data for the current item
                String name=dataList.get(i).get("Name").toString();
                Intent intent=new Intent(getActivity(),TalkActivity.class);
                startActivity(new Intent(getActivity(), TalkActivity.class));
                intent.putExtra("name",name);
                Toast.makeText(context,"Is the name of the option currently clicked?"+name,Toast.LENGTH_SHORT).show(); }}); }//list retrieves data
    public void getData(a){
        // Add the data from the traversal group to the list
        for (int i = 0; i < Names.length; i++) {
            // Create a map to store the data in the array
            HashMap<String, Object> map = new HashMap<String, Object>();
            map.put("Name",Names[i]);
            map.put("Image",Images[i]); dataList.add(map); }}}Copy the code

PeopleFragment

package com.czie.qq;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.Nullable;

public class PeopleFragment extends Fragment {

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_people,container,false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState); }}Copy the code

StatueFragment

package com.czie.qq;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.Nullable;

public class StatueFragment extends Fragment {

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_statue,container,false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState); }}Copy the code

Finally, use it in HomeActivity

Know what FragmentTransaction is

With fragments, actions such as adding, removing, and replacing can be performed through user interaction.

All of these changes form a set, which is called a transaction

HomeActivity

  • Listening to theImgaeViewClick event of
  • Initialize theImageViewCheck which is passed in as an argument to the methodImageViewClicked sets clicked state to false
  • showFragment(Fragment fragment)By hidingFragment, click on theImageViewAnd then determine which one to displayFragment
package com.czie.qq;

import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

@SuppressWarnings({"all"})
public class HomeActivity extends Activity implements View.OnClickListener {
    private ImageView messageImageView, peopleImageView, statueImageView;
    private MessageFragment messageFragment;
    private PeopleFragment peopleFragment;
    private StatueFragment statueFragment;
    private final FragmentManager fragmentManager = getFragmentManager();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        initView();
        initFragment();
        showFragment(statueFragment);
    }

    private void initView(a) {
        messageImageView = findViewById(R.id.messageImageView);
        peopleImageView = findViewById(R.id.peopleImageView);
        statueImageView = findViewById(R.id.statueImageView);
        messageImageView.setOnClickListener(this);
        peopleImageView.setOnClickListener(this);
        statueImageView.setOnClickListener(this);
    }

    private void initFragment(a) {
        messageFragment = new MessageFragment();
        peopleFragment = new PeopleFragment();
        statueFragment = new StatueFragment();

        / / display
        FragmentTransaction transaction = fragmentManager.beginTransaction();
        transaction.add(R.id.frameLayout, messageFragment);
        transaction.add(R.id.frameLayout, peopleFragment);
        transaction.add(R.id.frameLayout, statueFragment);
        transaction.commit();
    }


    @Override
    public void onClick(View view) {
        switch (view.getId()) {

            case R.id.messageImageView:
                init(messageImageView);
                showFragment(messageFragment);
                break;
            case R.id.peopleImageView:
                init(peopleImageView);
                showFragment(peopleFragment);
                //startActivity(new Intent(HomeActivity.this, ListViewActivity.class));
                break;
            case R.id.statueImageView:
                init(statueImageView);
                showFragment(statueFragment);
                break;
            default:
                break; }}public void init(ImageView imageView) {
        messageImageView.setSelected(false);
        peopleImageView.setSelected(false);
        statueImageView.setSelected(false);
        imageView.setSelected(true);
    }

    // Displays the specified Fragment
    // Define the current page
    private Fragment curFragment = new Fragment();

    public void showFragment(Fragment fragment) {
        // If the current fragment is the same as the incoming fragment, the fragment will be returned
        if (curFragment.equals(fragment)) {
            return; } FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.hide(messageFragment); transaction.hide(peopleFragment); transaction.hide(statueFragment); transaction.show(fragment); transaction.commit(); }}Copy the code

Matters needing attention

  • remembertransactionWant to commit

Preview the results!

4. Chat interface

item_talking.xml


      
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:padding="10dp"
    android:gravity="right">

    <TextView
        android:id="@+id/talkTextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="300dp"
        android:text="Sausage"
        android:textSize="25sp"
        android:textColor="# 000000"
        android:background="#cef"
        android:layout_marginStart="300dp">
    </TextView>

    <ImageView
        android:id="@+id/ImageView"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:background="@mipmap/kaochang">
    </ImageView>
</LinearLayout>
Copy the code

activity_talk.xml


      
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textColor="# 000000"
            android:text="Kang Xiao Zhuang"
            android:id="@+id/NameTextView"
            android:background="#44cef6">
        </TextView>
    <ListView
        android:id="@+id/listView2"
        android:layout_width="match_parent"
        android:layout_height="600dp"
        android:layout_weight="1"
        />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal"
            android:layout_gravity="bottom"
            >
            <EditText
                android:id="@+id/inputEditText"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1">
            </EditText>

            <Button
                android:id="@+id/sendButton"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="3"
                android:text="Send">
            </Button>
        </LinearLayout>
    </LinearLayout>
</RelativeLayout>
Copy the code

TalkActivity

  • throughHandlerTo implement the message sent after the dialog box set tonull
  • throughsimpleAdapterThe ID of the layout interface to which the implementation loads
package com.czie.qq;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TalkActivity extends Activity implements View.OnClickListener {
    private EditText inputEditText;
    private SimpleAdapter simpleAdapter;
    List<Map<String,String>> list=new ArrayList<Map<String,String>>();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_talk);
        Context context = this;
        initView();
        TextView nameTextView = findViewById(R.id.NameTextView);
        Intent intent=getIntent();
        String name=intent.getStringExtra("name");
        nameTextView.setText(name);
    }

    private void initView(a) {
        inputEditText=findViewById(R.id.inputEditText);
        Button sendButton = findViewById(R.id.sendButton);
        ListView listView2 = findViewById(R.id.listView2);
        listView2.setDivider(null);
        simpleAdapter=new SimpleAdapter(this,list,R.layout.item_talking,new String[]{"message"},new int[]{R.id.talkTextView});
        listView2.setAdapter(simpleAdapter);
        sendButton.setOnClickListener(this);

    }

    @Override
    public void onClick(View view) {
        sendMessage();
        handler.sendEmptyMessage(0);
    }

    public void sendMessage(a){
        String message=inputEditText.getText().toString();
        if (message.length()>0){
            HashMap<String, String> map = new HashMap<>();
            map.put("message",message);
            list.add(map);
            inputEditText.setText("");
        }
    }

    Handler handler=new Handler(){
        @Override
        public void handleMessage(@NonNull Message msg) { simpleAdapter.notifyDataSetChanged(); }}; }Copy the code

Conclusion:

  • Learned how to use simple page-hopping functions, improved thinking ability, learned how to use less code to achieve functions
  • Much work remains to be done

Write at the end:

  • Any mistakes are welcome to point out in the comments section, timely correction!