我已经使用SimpleCursorAdapter
列出了数据库中的名称,我想使用SimpleCursorAdapter.ViewBinder
的方法更改特定名称的颜色。我在运行此方法时遇到问题,我的数据库包含不同的名称,但ListView
将显示所有namse作为一个特定名称。我究竟做错了什么?如何更改特定名称的文本颜色?是否有可能使用ViewBinder
?使用SimpleCursorAdapter.ViewBinder更改Listview中的文本颜色
这是ViewBinder
我的部分代码:
SimpleCursorAdapter.ViewBinder binder = new SimpleCursorAdapter.ViewBinder() {
@Override
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
// TODO Auto-generated method stub
String[] temp = dh.return_result();
tv = (TextView)findViewById(R.id.textView1);
tv = (TextView) view;
for(int i = 0; i<temp.length; i++)
{
if(temp[i].equalsIgnoreCase("Ameer Zhann"))
{
tv.setText(temp[i]);
tv.setTextColor(Color.rgb(58, 58, 224));
return true;
}
}
return false;
}
};
,这是我的输出图像:
我该如何解决这个问题?
+1 – MKJParekh 2011-12-15 10:05:33