Hi guys,
My scenario:
-I'm using a list view in multiple choice mode to enable a user to
delete several items he/she has checked, at once.
-When the user clicks the delete button, i do the following:
-get positions of checked items using: myList.getCheckedItemPositions();
-Get the items in this position and put them to a list - toDeleteList.
-(QUESTION BASED ON THIS STEP) use myList.setItemChecked(position,
false) to uncheck the list item.
-Remove the items in the "toDeleteList"
Now, i was "forced" to manually uncheck the list item because the result of myList.getCheckedItemPositions() does not change after deleting from mylist.. i.e
-if, for example, I delete the 1st item (a) of list [a, b, c, d], b will appear checked after the delete ie. in list the list [b, c, d] - after deleting a.
Question is why? Because the SparseBooleanArray returned by myList.getCheckedItemPositions(); is the same before and after deleting from the list - using the adapter.
I thought (i could be wrong) that after removing an item from the list via the adapter, the CheckedItemPositions array should also change to reflect the new state of the list
eg.
- mylist = [a, b, c, d]
- then i check items at position 0 and 3 checked (a & d)
- the checked item positions (mylist.getCheckedItemPositions()) array now
has values true for positions 0 and 3
- If i remove a & d from the list, therefore, mylist = [b,c],
mylist.getCheckedItemPositions() is still the same as above ie. positions 0 and 3 are still checked after deleting items from the list (i think this is not normal - but again i could be wrong)
-I was expecting it not to be checked for positions 0 & 3 because the
items that were previously at these positions are no longer in the list.
i'm i getting something wrong here (or having the wrong
expectations :) ) ? someone please clarify this..
Thanks in advance,