How can I retrieve the positions of the selected item in a multichoice listView ? The getSelectedItemPosition method returns only the first one...
+3
A:
There is at most one selected item in a ListView
.
If your ListView
is CHOICE_MODE_SINGLE
or CHOICE_MODE_MULTIPLE
, you can use getCheckedItemPositions()
to get the checked ones.
CommonsWare
2009-08-27 16:44:34
Tnahk you for your answer.the method returns a SparseBooleanArray. How can i use this object to find the positions ?
2009-08-27 16:58:37
I have not used SparseBooleanArray. From the API, it appears you iterate over the size(), and for each index, you get the "key", which is a ListView position, and then get the value, which will be the boolean checked state of that position.
CommonsWare
2009-08-27 17:34:39