1

How can I retrieve the positions of the selected item in a multichoice listView? The getSelectedItemPosition method returns only the first one.

MysticMagicϡ
  • 28,593
  • 16
  • 73
  • 124

1 Answers1

10

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
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Tnahk you for your answer. the method returns a SparseBooleanArray. How can i use this object to find the positions ? –  Aug 27 '09 at 16:58
  • 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 Aug 27 '09 at 17:34