AI 144042: Fixes #1742109. Add a new API to ListView to return the list of checked items ids.
BUG=1742109 Automated import of CL 144042
This commit is contained in:
committed by
The Android Open Source Project
parent
096f41d539
commit
ad28bed52c
@@ -3219,6 +3219,29 @@ public class ListView extends AbsListView {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the set of checked items ids. The result is only valid if
|
||||
* the choice mode has not been set to {@link #CHOICE_MODE_SINGLE}.
|
||||
*
|
||||
* @return A new array which contains the id of each checked item in the list.
|
||||
*/
|
||||
public long[] getCheckItemIds() {
|
||||
if (mChoiceMode != CHOICE_MODE_NONE && mCheckStates != null && mAdapter != null) {
|
||||
final SparseBooleanArray states = mCheckStates;
|
||||
final int count = states.size();
|
||||
final long[] ids = new long[count];
|
||||
final ListAdapter adapter = mAdapter;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
ids[i]= adapter.getItemId(states.keyAt(i));
|
||||
}
|
||||
|
||||
return ids;
|
||||
}
|
||||
|
||||
return new long[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear any choices previously set
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user