1,在ListBean类中添加isSelectView; 生成get,set方法
private boolean isSelectView;
public boolean isSelectView() {
return isSelectView;
}
public void setSelectView(boolean selectView) {
isSelectView = selectView;
}
2,在adapter中给textView做选择判断
if (withdrawSetBean.isSelectView()){
//这里是选中的颜色
baseViewHolder.setTextColorRes(R.id.money_btn,R.color.colorFF6900);
}else{
//这里是未选中的颜色
baseViewHolder.setTextColorRes(R.id.money_btn,R.color.color_333333);
3,在条目监听里实现字体变色
//字体变色
List data =adapter.getData();
for (int i =0; i < data.size(); i++) {
ListModel.ListSetBean listBean = data.get(i);
listBean.setSelectView(i==position);
}
4,刷新adapter
adapter.notifyDataSetChanged();
网友评论