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:
Romain Guy
2009-04-01 11:46:43 -07:00
committed by The Android Open Source Project
parent 096f41d539
commit ad28bed52c
2 changed files with 35 additions and 1 deletions

View File

@ -122838,7 +122838,7 @@
<method name="setOrientation"
return="void"
abstract="false"
native="true"
native="false"
synchronized="false"
static="true"
final="false"
@ -150981,6 +150981,17 @@
visibility="public"
>
</method>
<method name="getCheckItemIds"
return="long[]"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
</method>
<method name="getCheckedItemPosition"
return="int"
abstract="false"

View File

@ -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
*/