GuidedAction
public class GuidedAction extends Action
GuidedDatePickerAction |
Subclass of GuidedAction that can choose a date. |
A data class which represents an action within a androidx.leanback.app.GuidedStepFragment. GuidedActions contain at minimum a title and a description, and typically also an icon.
A GuidedAction typically represents a single action a user may take, but may also represent a possible choice out of a group of mutually exclusive choices (similar to radio buttons), or an information-only label (in which case the item cannot be clicked).
GuidedActions may optionally be checked. They may also indicate that they will request further user input on selection, in which case they will be displayed with a chevron indicator.
GuidedAction recommends to use Builder. When application subclass GuidedAction, it can subclass BuilderBase, implement its own builder() method where it should call applyValues.
Summary
Nested types |
|---|
public class GuidedAction.Builder extends GuidedAction.BuilderBaseBuilds a |
public abstract class GuidedAction.BuilderBase<B extends GuidedAction.BuilderBase>Base builder class to build a |
Constants |
|
|---|---|
static final long |
ACTION_ID_CANCEL = -5Id of standard Cancel action. |
static final long |
ACTION_ID_CONTINUE = -7Id of standard Finish action. |
static final long |
ACTION_ID_CURRENT = -3When finishing editing, stay on current action. |
static final long |
ACTION_ID_FINISH = -6Id of standard Finish action. |
static final long |
ACTION_ID_NEXT = -2When finishing editing, goes to next action. |
static final long |
ACTION_ID_NO = -9Id of standard No action. |
static final long |
ACTION_ID_OK = -4Id of standard OK action. |
static final long |
ACTION_ID_YES = -8Id of standard Yes action. |
static final int |
Checkset Id for checkbox. |
static final int |
Default checkset Id for radio. |
static final int |
NO_CHECK_SET = 0Special check set Id that is neither checkbox nor radio. |
Protected constructors |
|---|
Public methods |
|
|---|---|
String[] |
Returns autofill hints, see |
int |
Returns the check set id this action is a part of. |
@Nullable CharSequence |
Returns the description of this action. |
int |
Returns InputType of action description in editing; only valid when |
int |
Returns InputType of action description not in editing. |
@Nullable CharSequence |
Returns the optional description text to edit. |
int |
Returns InputType of action title in editing; only valid when |
@Nullable CharSequence |
Returns the optional title text to edit. |
int |
Returns InputType of action title not in editing. |
@Nullable Intent |
Returns the intent associated with this action. |
@Nullable List<GuidedAction> |
|
@Nullable CharSequence |
getTitle()Returns the title of this action. |
boolean |
Returns whether this action can be activated to edit, e.g. a DatePicker. |
boolean |
Returns whether this action is has a multiline description. |
boolean |
hasNext()Returns whether this action will request further user input when selected, such as showing another GuidedStepFragment or launching a new activity. |
boolean |
|
boolean |
Returns if this action has editable title or editable description. |
boolean |
infoOnly()Returns whether the action will only display information and is thus not clickable. |
final boolean |
Returns true if Action will be saved to instanceState and restored later, false otherwise. |
boolean |
Returns whether this action is checked. |
boolean |
Returns whether this action description is editable. |
boolean |
Returns true if |
boolean |
Returns whether this action title is editable. |
boolean |
Returns whether this action is enabled. |
boolean |
Returns whether this action is focusable. |
void |
onRestoreInstanceState(@NonNull Bundle bundle, @NonNull String key)Restore action from a bundle using a given key. |
void |
onSaveInstanceState(@NonNull Bundle bundle, @NonNull String key)Save action into a bundle using a given key. |
void |
setChecked(boolean checked)Sets whether this action is checked. |
void |
setDescription(@Nullable CharSequence description)Sets the description of this action. |
void |
setEditDescription(@Nullable CharSequence editDescription)Sets the optional description text to edit instead of |
void |
setEditTitle(@Nullable CharSequence editTitle)Sets the optional title text to edit instead of |
void |
setEnabled(boolean enabled)Sets whether this action is enabled. |
void |
setFocusable(boolean focusable)Sets whether this action is focusable. |
void |
Sets the intent of this action. |
void |
setSubActions(@Nullable List<GuidedAction> actions)Change sub actions list. |
void |
setTitle(@Nullable CharSequence title)Sets the title of this action. |
Inherited Constants |
||
|---|---|---|
|
Inherited methods |
||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Constants
ACTION_ID_CANCEL
public static final long ACTION_ID_CANCEL = -5
Id of standard Cancel action.
ACTION_ID_CONTINUE
public static final long ACTION_ID_CONTINUE = -7
Id of standard Finish action.
ACTION_ID_CURRENT
public static final long ACTION_ID_CURRENT = -3
When finishing editing, stay on current action.
ACTION_ID_FINISH
public static final long ACTION_ID_FINISH = -6
Id of standard Finish action.
ACTION_ID_NEXT
public static final long ACTION_ID_NEXT = -2
When finishing editing, goes to next action.
CHECKBOX_CHECK_SET_ID
public static final int CHECKBOX_CHECK_SET_ID = -1
Checkset Id for checkbox.
DEFAULT_CHECK_SET_ID
public static final int DEFAULT_CHECK_SET_ID = 1
Default checkset Id for radio.
NO_CHECK_SET
public static final int NO_CHECK_SET = 0
Special check set Id that is neither checkbox nor radio.
Protected constructors
Public methods
getAutofillHints
public String[] getAutofillHints()
Returns autofill hints, see setAutofillHints.
getCheckSetId
public int getCheckSetId()
Returns the check set id this action is a part of. All actions in the same list with the same check set id are considered linked. When one of the actions within that set is selected, that action becomes checked, while all the other actions become unchecked.
| Returns | |
|---|---|
int |
an integer representing the check set this action is a part of, or |
getDescription
public @Nullable CharSequence getDescription()
Returns the description of this action.
| Returns | |
|---|---|
@Nullable CharSequence |
The description of this action. |
getDescriptionEditInputType
public int getDescriptionEditInputType()
Returns InputType of action description in editing; only valid when isDescriptionEditable is true.
| Returns | |
|---|---|
int |
InputType of action description in editing. |
getDescriptionInputType
public int getDescriptionInputType()
Returns InputType of action description not in editing.
| Returns | |
|---|---|
int |
InputType of action description not in editing. |
getEditDescription
public @Nullable CharSequence getEditDescription()
Returns the optional description text to edit. When not null, it is being edited instead of getDescription.
| Returns | |
|---|---|
@Nullable CharSequence |
Optional description text to edit instead of |
getEditInputType
public int getEditInputType()
Returns InputType of action title in editing; only valid when isEditable is true.
| Returns | |
|---|---|
int |
InputType of action title in editing. |
getEditTitle
public @Nullable CharSequence getEditTitle()
Returns the optional title text to edit. When not null, it is being edited instead of getTitle.
| Returns | |
|---|---|
@Nullable CharSequence |
Optional title text to edit instead of |
getInputType
public int getInputType()
Returns InputType of action title not in editing.
| Returns | |
|---|---|
int |
InputType of action title not in editing. |
getIntent
public @Nullable Intent getIntent()
Returns the intent associated with this action.
getSubActions
public @Nullable List<GuidedAction> getSubActions()
| Returns | |
|---|---|
@Nullable List<GuidedAction> |
List of sub actions or null if sub actions list is not enabled. |
getTitle
public @Nullable CharSequence getTitle()
Returns the title of this action.
| Returns | |
|---|---|
@Nullable CharSequence |
The title set when this action was built. |
hasEditableActivatorView
public boolean hasEditableActivatorView()
Returns whether this action can be activated to edit, e.g. a DatePicker.
| Returns | |
|---|---|
boolean |
true if the action can be activated to edit. |
hasMultilineDescription
public boolean hasMultilineDescription()
Returns whether this action is has a multiline description.
| Returns | |
|---|---|
boolean |
true if the action was constructed as having a multiline description, false otherwise. |
hasNext
public boolean hasNext()
Returns whether this action will request further user input when selected, such as showing another GuidedStepFragment or launching a new activity. Configured during construction.
| Returns | |
|---|---|
boolean |
true if the action will request further user input when selected, false otherwise. |
hasSubActions
public boolean hasSubActions()
| Returns | |
|---|---|
boolean |
True if has sub actions list, even it's currently empty. |
hasTextEditable
public boolean hasTextEditable()
Returns if this action has editable title or editable description.
| Returns | |
|---|---|
boolean |
True if this action has editable title or editable description, false otherwise. |
infoOnly
public boolean infoOnly()
Returns whether the action will only display information and is thus not clickable. If both this and hasNext are true, infoOnly takes precedence. The default is false. For example, this might represent e.g. the amount of storage a document uses, or the cost of an app.
| Returns | |
|---|---|
boolean |
true if will only display information, false otherwise. |
isAutoSaveRestoreEnabled
public final boolean isAutoSaveRestoreEnabled()
Returns true if Action will be saved to instanceState and restored later, false otherwise. The default value is true. When isAutoSaveRestoreEnabled() is true and getId is not NO_ID:
isEditableis true: save text ofgetTitleisDescriptionEditableis true: save text ofgetDescriptiongetCheckSetIdis notNO_CHECK_SET: saveisChecked}GuidedDatePickerActionwill be saved
| Returns | |
|---|---|
boolean |
True if Action will be saved to instanceState and restored later, false otherwise. |
isChecked
public boolean isChecked()
Returns whether this action is checked.
| Returns | |
|---|---|
boolean |
true if the action is currently checked, false otherwise. |
isDescriptionEditable
public boolean isDescriptionEditable()
Returns whether this action description is editable.
| Returns | |
|---|---|
boolean |
true if the action description is editable, false otherwise. |
isEditTitleUsed
public boolean isEditTitleUsed()
Returns true if getEditTitle is not null. When true, the getEditTitle is being edited instead of getTitle.
| Returns | |
|---|---|
boolean |
true if |
isEditable
public boolean isEditable()
Returns whether this action title is editable.
| Returns | |
|---|---|
boolean |
true if the action title is editable, false otherwise. |
isEnabled
public boolean isEnabled()
Returns whether this action is enabled.
| Returns | |
|---|---|
boolean |
true if the action is currently enabled, false otherwise. |
isFocusable
public boolean isFocusable()
Returns whether this action is focusable.
| Returns | |
|---|---|
boolean |
true if the action is currently focusable, false otherwise. |
onRestoreInstanceState
public void onRestoreInstanceState(@NonNull Bundle bundle, @NonNull String key)
Restore action from a bundle using a given key. When isAutoRestore() is true:
isEditableis true: save text ofgetTitleisDescriptionEditableis true: save text ofgetDescriptiongetCheckSetIdis notNO_CHECK_SET: saveisChecked}GuidedDatePickerActionwill be saved
onSaveInstanceState
public void onSaveInstanceState(@NonNull Bundle bundle, @NonNull String key)
Save action into a bundle using a given key. When isAutoRestoreEna() is true:
isEditableis true: save text ofgetTitleisDescriptionEditableis true: save text ofgetDescriptiongetCheckSetIdis notNO_CHECK_SET: saveisChecked}GuidedDatePickerActionwill be saved
setChecked
public void setChecked(boolean checked)
Sets whether this action is checked.
| Parameters | |
|---|---|
boolean checked |
Whether this action should be checked. |
setDescription
public void setDescription(@Nullable CharSequence description)
Sets the description of this action.
| Parameters | |
|---|---|
@Nullable CharSequence description |
The description of the action. |
setEditDescription
public void setEditDescription(@Nullable CharSequence editDescription)
Sets the optional description text to edit instead of setDescription.
| Parameters | |
|---|---|
@Nullable CharSequence editDescription |
Optional description text to edit instead of |
setEditTitle
public void setEditTitle(@Nullable CharSequence editTitle)
Sets the optional title text to edit instead of setTitle.
| Parameters | |
|---|---|
@Nullable CharSequence editTitle |
Optional title text to edit instead of |
setEnabled
public void setEnabled(boolean enabled)
Sets whether this action is enabled.
| Parameters | |
|---|---|
boolean enabled |
Whether this action should be enabled. |
setFocusable
public void setFocusable(boolean focusable)
Sets whether this action is focusable.
| Parameters | |
|---|---|
boolean focusable |
Whether this action should be focusable. |
setIntent
public void setIntent(@Nullable Intent intent)
Sets the intent of this action.
setSubActions
public void setSubActions(@Nullable List<GuidedAction> actions)
Change sub actions list.
| Parameters | |
|---|---|
@Nullable List<GuidedAction> actions |
Sub actions list to set on this action. Sets null to disable sub actions. |
setTitle
public void setTitle(@Nullable CharSequence title)
Sets the title of this action.
| Parameters | |
|---|---|
@Nullable CharSequence title |
The title set when this action was built. |