我想更改班级列表中缺席的学生的文字颜色。
我有
ArrayList<HashMap<String, String>> studentList = studentList = new ArrayList<HashMap<String, String>>();
并将字符串放在
中HashMap<String, String> map = new HashMap<String, String>();
map.put("idno", sidno);
map.put("fullname", sfullname);
map.put("attendance", attendance);
studentList.add(map);
我使用像这样的SimpleAdapter将studentList
放在listview中
ListAdapter adapter = new SimpleAdapter(CheckAttendanceActivity.this, studentList, R.layout.list_students, new String[]{"idno", "fullname", "attendance"}, new int[]{R.id.idno, R.id.fullname, R.id.attendance});
setListAdapter(adapter);
它完美地显示了学生列表,但我想从attendance == "absent"
ArrayList更改具有studentList
的学生的文本颜色。我该怎么做?
答案 0 :(得分:1)
在Adapter
的{{1}}方法中,检查是否getView
,然后更改背景颜色
答案 1 :(得分:1)
public virtual actionresult value(string value)
{
var list = value.Split('#');
if (list != null )
{
ArrayList arr = new ArrayList();
for (int i = 0; i < list.Length; i++)
{
foreach (var key in list)
{
if (key == null || string.IsNullOrEmpty(key.Trim()))
{
continue;
}
var nric = key.Split('|')[0];
var dob = key.Split('|')[1];
s.NRIC = nric;
s.DOB = Convert.ToDateTime(dob);
arr.Add(s);
}
}
}
}