listview with multiple_choice problem
SparseBooleanArray selectedItem=catogoryList.getCheckedItemPositions();
for(int i=0;i<selectedItem.size();i++)
{
System.out.println("Array val:"+selectedItem.valueAt(i));
if(selectedItem.valueAt(i))
{
if(temp.cont开发者_Python百科ains(list.get(position)))
{}
else
temp.add(list.get(position));
}
else
{
temp.remove(list.get(position));
}
}
I use listview with multiple_choice (listview with checkbox) when i get items in listview that is checked with out scrolling i received correct values if i scroll the listview i don't get correct values. i found that selectedItem.valueAt(i) i get false when i check the items while scrolling. i don't know why false value is returned instead of true value.
How do you obtain your values? This process should be like this:
SparseBooleanArray checked = getCheckedItemPositions();
List<String> checkedResult = new ArrayList<String>();
for (int i = 0; i < checked.size(); i++) {
if (checked.valueAt(i)) {
checkedResult.add(getAdapter().getItem(checked.keyAt(i)).toString());
}
}
return checkedResult;
精彩评论