我ListView
有多个选项,我希望每当用户检查多个项目时,都会返回所有选中的值。
SparseBooleanArray checked = lv.getCheckedItemPositions();
ArrayList<String> selectedItems = new ArrayList<String>();
for (int i = 0; i < checked.size(); i++) {
int position = checked.keyAt(i);
if (checked.valueAt(i))
selectedItems.add(String.valueOf(ard.getItem(position)));
}
String[] outputStrArr = new String[selectedItems.size()];
for (int i = 0; i < selectedItems.size(); i++) {
outputStrArr[i] = selectedItems.get(i);
Pushbots.sharedInstance().setAlias(outputStrArr[i]);
}
...
在这种情况下,只有最后检查的值...