我有一个显示项目列表的 ListView。当我单击一个项目时,我在我的数据库表中将该项目标记为已删除。然后,我使用 SimpleCursorAdapter、setViewBinder、setViewValue 更新列表。
我检查是否为相应的项目设置了已删除的列,然后更新 TextView 以删除该项目。
代码如下
Cursor c = db.fetchAllNotes(id);
startManagingCursor(c);
String[] from = new String[] { DatabaseHandler.KEY_LIST };
int[] to = new int[] { R.id.text1 };
SimpleCursorAdapter notes =
new SimpleCursorAdapter(this, R.layout.task_row, c, from, to);
notes.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
// TODO Auto-generated method stub
text = (TextView) view.findViewById (R.id.text1);
System.out.println("Item is "+ text.getText().toString());
System.out.println("Item from cursor is " + cursor.getString(2));
System.out.println("Striked value is " + Integer.parseInt(cursor.getString(3)));
if(Integer.parseInt(cursor.getString(3)) == 1)
text.setPaintFlags(textViewItem.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
return false;
}
});
setListAdapter(notes);
我究竟做错了什么?