【发布时间】:2016-11-14 15:59:36
【问题描述】:
我试过this 和holder.setIsRecyclable(false);
但我无法保持视图的背景
任何指导都会很棒
编辑:代码
holder.setIsRecyclable(false);
final GradientDrawable gd2=new GradientDrawable();
gd2.setShape(GradientDrawable.OVAL);
gd2.setSize(24,24);
gd2.setStroke(2, Color.parseColor("#5FB382"));
final GradientDrawable gd = new GradientDrawable();
gd.setShape(GradientDrawable.OVAL);
gd.setStroke(2, Color.parseColor("#FBAA35"));
gd.setSize(24,24);
holder.favorite.setTextColor(Color.parseColor("#FBAA35"));
holder.hatIcon.setTextColor(Color.parseColor("#5FB382"));
holder.hatIcon.getCurrentTextColor();
holder.hatIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (holder.hatIcon.getCurrentTextColor() == Color.parseColor("#5FB382")) {
holder.hatIcon.setTextColor(Color.parseColor("#ffffff"));
holder.hatIcon.setBackgroundColor(Color.parseColor("#5FB382"));
gd2.setColor(Color.parseColor("#5FB382"));
}
else {
Debug.e();
holder.hatIcon.setTextColor(Color.parseColor("#5FB382"));
gd2.setColor(Color.parseColor("#ffffff"));
}
}
});
【问题讨论】:
-
@MarcinKunert 更新了代码
标签: android android-recyclerview