I have a ListView that is populated using a custom CursorAdapter. Within BindView, I have the following code:
CheckBox mCheckBox = (CheckBox) view.findViewById(R.id.list_done);
mCheckBox.setChecked(isDone);
mCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
AW.getDB().updateTask(c.getInt(c.getColumnIndex(ToDoDBAdapter.KEY_ID)), isChecked);
TD.displayTasks();
}
});
However, when one of the checkboxes in the list is set, it seems as though the code that runs applies to the cursor's position as of the last item in the list. Thus, in a list of 4 items where
c.getInt(c.getColumnIndex(ToDoDBAdapter.KEY_ID))
should return 1, 2, 3, 4 respectively, checking either of the 4 boxes gives the value 4. Anyone know why this is?
In other words, the onCheckedChangedListener is the same for every CheckBox in the list.