我重写 SimpleAdapter:
class NoticelistAdapter extends SimpleAdapter
{
public NoticelistAdapter(Context context,
List<? extends Map<String, ?>> data, int resource,
String[] from, int[] to)
{
super(context, data, resource, from, to);
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
Map<String,Object> map= list.get(position);
int readState = (Integer) map.get("ReadState");
if (readState == 1)
{
// do something to change the color of title
}
return convertView;
}
}
适配器是:
adapter = new NoticelistAdapter(NoticelistActivity.this, list, R.layout.row_noticelist,
new String[] { "Title", "RealName","Date"},
new int[] { R.id.noticetitle, R.id.noticerealname,R.id.noticedate});
每个映射中都有一个名为“readstate”的int参数,如果readstate == 1,那么我想将“Title”(TextView)的颜色更改为另一种颜色。我知道我应该在我的适配器中覆盖 getView(...),但我不知道该怎么做。请你帮帮我。先感谢您。