-1
假设您必须为RecyclerView
创建一个小型ImageButton
的列表,每个具有不同的颜色或背景。在Android中为RecyclerView创建ImageButtons模型类的正确方法
哪一个模型类是正确的方法?
,其延伸的ImageButtonpublic class ColorButton2 extends ImageButton{
private Context context;
private boolean isPlain, isWallpaper, isTextured;
private int color;
public ColorButton2(Context context,int color,boolean isPlain,boolean isTextured, boolean isWallpaper) {
super(context);
this.color = color;
this.isPlain = isPlain;
this.isWallpaper = isWallpaper;
this.isTextured = isTextured;
}
具有的ImageButton作为成员变量的类
模型类:
public class ColorButton2{
private ImageButton imageButton
private Context context;
private boolean isPlain, isWallpaper, isTextured;
private int color;
public ColorButton2(Context context,int color,boolean isPlain,boolean isTextured, boolean isWallpaper) {
super(context);
this.color = color;
this.isPlain = isPlain;
this.isWallpaper = isWallpaper;
this.isTextured = isTextured;
}
吸气剂和setter是代码的过程的一部分。