@MainThread public class SingleChoiceMode extends ObservableChoiceMode
ChoiceMode that allows up to one choice.| Constructor and Description |
|---|
SingleChoiceMode() |
SingleChoiceMode(Bundle savedInstanceState) |
| Modifier and Type | Method and Description |
|---|---|
void |
clearChoices()
Clears any checked items.
|
long |
getCheckedItem()
Returns an identifier of checked item or
RecyclerView#NO_ID if no item is checked. |
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 |
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.
|
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 |
setChoiceModeListener(SimpleChoiceModeListener listener)
Sets single choice mode callback.
|
void |
setItemChecked(long itemId,
boolean checked)
Sets the checked state of the specified position.
|
isAttached, notifyAllItemsCheckedChanged, notifyItemCheckedChanged, registerChoiceModeObserver, unregisterChoiceModeObserverpublic void setChoiceModeListener(@Nullable SimpleChoiceModeListener listener)
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.public long getCheckedItem()
RecyclerView#NO_ID if no item is checked.public void clearChoices()
public boolean onClick(long itemId)
itemId - The item id which has been clicked.public boolean onLongClick(long itemId)
itemId - The item id which has been clicked.