如何将背景颜色添加到整行,而不仅仅是在R.id.data列上?
adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
if (view.getId() == R.id.data)
{
if(cursor.getPosition() % 2 == 0)
{
view.setBackgroundColor(Color.LTGRAY);
}
else {
view.setBackgroundColor(Color.CYAN);
}
return false;
}
return false;}
});
答案 0 :(得分:0)
使用此代码,我将背景颜色正确设置为整行!
{
((View) view.getParent().getParent()).setBackgroundColor(Color.parseColor("RED"));
}
但如何将文字颜色设置为整行?
((TextView) view.getParent().getParent()).setTextColor(Color.RED);
不起作用!