Android开发日志(3)

------------恢复内容开始------------

CardView+Searchview

1.进入gradle中导入

implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'

2.修改activity_main.xml

3.new->layoutresoucefile:

 

Android开发日志(3)

 

 设置

cardCornerRadius="4dp"

4.New->javaclass->ExampleItem

5.

package com.example.recyclerviewproject;

public class ExampleItem {
    private int mImageResource;
    private String mText1;
    private String mText2;

    public ExampleItem(int imageResource, String text1, String text2){
        mImageResource = imageResource;
        mText1 = text1;
        mText2 = text2;

    }

    public int getmImageResource(){
        return  mImageResource;
    }

    public String getmText1(){
        return mText1;
    }
    public String getmTExt2(){
        return mText2;
    }

}

6.创建newcalss

Android开发日志(3)

 

 Caution1!:androidx导入recyclerview方法:

import androidx.recyclerview.widget.RecyclerView;

------------恢复内容结束------------

上一篇:Android-----AppBarLayout 的使用


下一篇:AndroidX与原始 Android 支持库