@MainThread public interface ChoiceMode
| Modifier and Type | Method and Description |
|---|---|
void |
clearChoices()
Clears any checked items.
|
int |
getCheckedItemCount()
Returns the number of items currently selected.
|
boolean |
isActivated()
Returns true if choice mode is active.
|
boolean |
isItemChecked(long itemId)
Returns the checked state of the specified position.
|
boolean |
onClick(long itemId)
Dispatches click on a specific item.
|
boolean |
onLongClick(long itemId)
Dispatches long click on a specific item.
|
void |
registerChoiceModeObserver(ChoiceModeObserver observer)
Register a new observer to listen for selection changes.
|
boolean |
requiresLongpress()
Returns whether long press is required by this choice mode.
|
boolean |
requiresStableIds()
Returns whether stable item ids are required by this choice mode.
|
void |
setItemChecked(long itemId,
boolean checked)
Sets the checked state of the specified position.
|
void |
unregisterChoiceModeObserver(ChoiceModeObserver observer)
Unregister an observer currently listening for selection changes.
|
boolean requiresStableIds()
boolean requiresLongpress()
boolean isActivated()
int getCheckedItemCount()
To determine the specific items that are currently selected, use one of
the getChecked* methods.
boolean isItemChecked(long itemId)
itemId - The item whose checked state to return.false.void setItemChecked(long itemId,
boolean checked)
itemId - The item id whose checked state is to be checked.checked - The new checked state for the item.void clearChoices()
boolean onClick(long itemId)
itemId - The item id which has been clicked.boolean onLongClick(long itemId)
itemId - The item id which has been clicked.void registerChoiceModeObserver(@NonNull ChoiceModeObserver observer)
The choice mode may publish a variety of events describing selection changes.
Components registering observers with a choice mode are responsible for
unregisterChoiceModeObserver(ChoiceModeObserver)
unregistering} those observers when finished.
observer - Observer to register.unregisterChoiceModeObserver(ChoiceModeObserver)void unregisterChoiceModeObserver(@NonNull ChoiceModeObserver observer)
The unregistered observer will no longer receive events about changes to the choice mode.
observer - Observer to unregister.registerChoiceModeObserver(ChoiceModeObserver)