這是一個後續問題,這個問題:讓所有列表視圖檢查索引
Retrieving the selected items from a multi-select ListView
我使用的是ListView
與模式CHOICE_MODE_MULTIPLE_MODAL
。
有沒有辦法獲得所有檢查項目的索引?在我上面發佈的問題中,有一個建議使用方法getCheckedItemPositions()
,但我不想遍歷整個列表並檢查它是否返回true,所以這不是我所需要的。我想做這樣的事情(僞代碼):
int[] checkedPositions = list.getCheckedIndexes();
for(int index : checkedPositions)
{
list.remove(index);
}
有沒有辦法做到這樣的事情?
可能重複[如何獲得所有從一個ListView檢查項目?(http://stackoverflow.com/questions/4831918/how-to-all-checked-items-from-a-listview) – nkorth