listview 变灰色

1.在getview()中写如下代码,根据id,看是否存在存在就变色


String idArray = CacheUtils.getString(context, READ_ARRAY_ID);//35311,35312,

if (idArray.contains(newsEntity.getId() + "")) {
viewHolder.tv_title .setTextColor(Color.GRAY);
} else {
viewHolder.tv_title .setTextColor(Color.BLACK);

}


2.给listview设置点击监听

TabDetailPagerBean.DataEntity.NewsEntity newsEntity = dataNews.get(position);
String idArray = CacheUtils.getString( context, READ_ARRAY_ID);
if (idArray.contains(newsEntity.getId() + "")) {
String values = idArray + newsEntity.getId() + ",";
//""+35311+"," == 35311,35312
CacheUtils.putString(context, READ_ARRAY_ID, values);
mylistAdapter .notifyDataSetChanged();

你可能感兴趣的:(安卓)