I have a ListView which displays a list of items. When I click on an item, I mark the item as striked in my database table. Then, I update the list using a SimpleCursorAdapter, setViewBinder, setViewValue.
I check if the striked column is set for a corresponding item, and then I update the TextView to strike the item.
The code is below
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);
What am I doing wrong?