public class MultipleModalChoiceMode extends ObservableChoiceMode
ChoiceMode that allows multiple choices in a modal selection mode.| Constructor and Description |
|---|
MultipleModalChoiceMode(ActionModeCompat actionModeCompat,
ModalChoiceModeListener listener) |
MultipleModalChoiceMode(ActionModeCompat actionModeCompat,
ModalChoiceModeListener listener,
Bundle savedInstanceState) |
| Modifier and Type | Method and Description |
|---|---|
void |
clearChoices()
Clears any checked items.
|
void |
finish()
Finish and close this action mode.
|
int |
getCheckedItemCount()
Returns the number of items currently selected.
|
LongArrayList |
getCheckedItems()
Returns an unsorted
LongArrayList of checked item ids. |
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 |
onSaveInstanceState(Bundle outState)
Call this method to retrieve per-instance state before UI component being killed
so that the state can be restored via constructor.
|
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 |
setFinishActionModeOnClearEnabled(boolean enabled)
Allows action mode be opened when no items are checked.
|
void |
setItemChecked(long itemId,
boolean checked)
Sets the checked state of the specified position.
|
void |
setStartOnSingleTapEnabled(boolean enabled)
Allows to start modal choice on single tap.
|
void |
unregisterChoiceModeObserver(ChoiceModeObserver observer)
Unregister an observer currently listening for selection changes.
|
isAttached, notifyAllItemsCheckedChanged, notifyItemCheckedChangedpublic MultipleModalChoiceMode(@NonNull ActionModeCompat actionModeCompat, @NonNull ModalChoiceModeListener listener)
public MultipleModalChoiceMode(@NonNull ActionModeCompat actionModeCompat, @NonNull ModalChoiceModeListener listener, @Nullable Bundle savedInstanceState)
public void setStartOnSingleTapEnabled(boolean enabled)
public void setFinishActionModeOnClearEnabled(boolean enabled)
public boolean requiresStableIds()
public boolean requiresLongpress()
public boolean isActivated()
public int getCheckedItemCount()
To determine the specific items that are currently selected, use one of
the getChecked* methods.
public boolean isItemChecked(long itemId)
itemId - The item whose checked state to return.false.public 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.@NonNull public LongArrayList getCheckedItems()
LongArrayList of checked item ids.
Don't modify it without copying.public void clearChoices()
public boolean onClick(long itemId)
ChoiceModeitemId - The item id which has been clicked.public boolean onLongClick(long itemId)
ChoiceModeitemId - The item id which has been clicked.public 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
ChoiceMode.unregisterChoiceModeObserver(ChoiceModeObserver)
unregistering} those observers when finished.
registerChoiceModeObserver in interface ChoiceModeregisterChoiceModeObserver in class ObservableChoiceModeobserver - Observer to register.ChoiceMode.unregisterChoiceModeObserver(ChoiceModeObserver)public void unregisterChoiceModeObserver(@NonNull ChoiceModeObserver observer)
The unregistered observer will no longer receive events about changes to the choice mode.
unregisterChoiceModeObserver in interface ChoiceModeunregisterChoiceModeObserver in class ObservableChoiceModeobserver - Observer to unregister.ChoiceMode.registerChoiceModeObserver(ChoiceModeObserver)public void finish()
ModalChoiceModeListener will
have its ModalChoiceModeListener#onDestroyActionMode(ActionMode) method called.