RecyclerView的使用方法实例分析
话不多说直接上代码
主文件的布局文件,定义一个RecyclerView列表
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="宠物商店"
android:textSize="30sp"
android:gravity="center"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textColor="#D3C79A"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/tv"
android:background="#F1F1E1"/>
</RelativeLayout>
(效果图)
需要调用的自己定义的布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android