0

I have a ListView of items with checkboxes.

I have a custom CursorAdapter that checks the checkboxes if the the field value is "1" in it's get View method.

When I click on the list item in the listview, it checks the checkbox and updates the field to "1". The problem I have is when I call the changecursor method on my custom adapter, it reloads everything and points to the first item instead of the item I just clicked on.

In the changeCursor method I have the following:

    public void changeCursor(Cursor cursor) {
    super.changeCursor(cursor);
    init(cursor);
    notifyDataSetChanged();
}

Is there a way to maintain the position or a workaround to reload the cursor without making it jump to the first item?

Maurice
  • 6,413
  • 13
  • 51
  • 76

1 Answers1

1

You basically need some data structure to keep track of checked items. you can use boolean array in your custom adapter.

for more info refer this link Custom listview with checkbox problem

listview with checkbox

if you are looking for an example try this http://appfulcrum.com/?p=281 tutorial which solves the checkbox problem in listview using shared preferences.

Thanks

Community
  • 1
  • 1
bHaRaTh
  • 3,464
  • 4
  • 34
  • 32
  • Ok I have a problem. here goes hope it makes sense. When I load the listview using getView, meaning i get the values from the cursor, I set the boolean value in the arrayList using this value. I then use this arraylist to display the checkboxes. No problem there. The problem starts when he checks the checkbox. The data changes but the cursor remains the same. I set the value of the position to true in the arrayList, but when getView gets called, it triggers the OLD cursor and loads the old data overwriting the arraylist boolean value to false. – Maurice Nov 15 '11 at 04:11