-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是代碼的過程的一部分。