I have a multiselection listview in my android app. What I need to know is how many items on that list I have selectet.
A:
I found a solution. getCheckedItemPositions() will create a SparceBooleanArray. So it is just to count the elements which are true in that array.
Eksample:
int counter = 0; for(int i = 0; i < theArray.size(); i++){ if(theListView.getCheckedItemPositions().get(i)) counter ++; }
IronMonkey
2010-10-09 16:41:15
You could also use: `theListView.getCheckedItemIds().size();` Not sure if this will be faster (depends on internal implementation), but it might be a little clearer to other people looking at the code.
Grant Peters
2010-10-09 16:53:05
but the array created by getChekItemIds() does not get smaller when you uncheck an item.
IronMonkey
2010-10-09 23:28:38