2

Sorry for the silly question. I know how to get checked items from ListView (MultipleChoice) with a SparseBooleanArray. But how to get the unchecked items?

Tim
  • 6,692
  • 2
  • 25
  • 30
tehnolog
  • 1,204
  • 1
  • 11
  • 23

1 Answers1

2

Handling the SparseBooleanArray is pretty simple once you get it. If you know which items are checked you should be able to know which items are not checked by making the assumption that all items that are not in the checked positions are unchecked.

    SparseBooleanArray checkedPositions = list.getCheckedItemPositions();
    for(int i=0; i<myList.size(); i++) {
      if(checkedPositions.get(i)) {
        // CHECKED
      } else {
        // NOT CHECKED
      }
    }
Tim
  • 6,692
  • 2
  • 25
  • 30
  • Thanks, Tim. But how to get unchecked items in array? SparseBooleanArray uncheckedPosition = ? – tehnolog Jul 28 '12 at 09:01
  • I think my code snippet makes that pretty obvious. All the items in the else part are unchecked.. There is no other way to get them. – Tim Jul 28 '12 at 09:21