tehnolog
tehnolog

Reputation: 1214

Get unchecked items in Listview with MultipleChoice

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?

Upvotes: 2

Views: 1282

Answers (1)

Tim
Tim

Reputation: 6712

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
      }
    }

Upvotes: 2

Related Questions