我知道如何使用bindView在listview上设置颜色。因此,每当它被创建(或滚动到屏幕上)时,颜色就会被设置...
但是,如果我不想销毁并重新创建整个视图,该怎么做呢?
也就是说,如果我按下一个按钮,我希望突出显示所有当前屏幕上的项目(在listview中),这些项目的第二个字段在游标中等于False
。
Item 1, True
Item 2, True
Item 3, False -- Should highlight Green on button press.
Item 4, True
编辑:
目前我这样做,但需要刷新光标。
int currentPosition = lv.getFirstVisiblePosition(); // Obtain where list is
lv.setAdapter(null);
Cursor cursor = SqlDB.getCursor();
adap = new MyAdaptor(this, R.layout.list, cursor, columns, to, true, 0);
lv.setAdapter(adap);
lv.setSelection(currentPosition); // Move back to where it was
SimpleCursorAdapter
,但只是一个自定义布局。 - Mcloving