added in version 22.1.0
belongs to Maven artifact com.android.support:leanback-v17:28.0.0-alpha1

GuidedAction

public class GuidedAction
extends Action

java.lang.Object
   ↳ android.support.v17.leanback.widget.Action
     ↳ android.support.v17.leanback.widget.GuidedAction
Known Direct Subclasses


A data class which represents an action within a 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 GuidedAction.Builder. When application subclass GuidedAction, it can subclass GuidedAction.BuilderBase, implement its own builder() method where it should call applyValues(GuidedAction).

Summary

Nested classes

class GuidedAction.Builder

Builds a GuidedAction object. 

class GuidedAction.BuilderBase<B extends BuilderBase>

Base builder class to build a GuidedAction object. 

Constants

long ACTION_ID_CANCEL

Id of standard Cancel action.

long ACTION_ID_CONTINUE

Id of standard Finish action.

long ACTION_ID_CURRENT

When finishing editing, stay on current action.

long ACTION_ID_FINISH

Id of standard Finish action.

long ACTION_ID_NEXT

When finishing editing, goes to next action.

long ACTION_ID_NO

Id of standard No action.

long ACTION_ID_OK

Id of standard OK action.

long ACTION_ID_YES

Id of standard Yes action.

int CHECKBOX_CHECK_SET_ID

Checkset Id for checkbox.

int DEFAULT_CHECK_SET_ID

Default checkset Id for radio.

int NO_CHECK_SET

Special check set Id that is neither checkbox nor radio.

Inherited constants

From class android.support.v17.leanback.widget.Action

Protected constructors

GuidedAction()

Public methods

int getCheckSetId()

Returns the check set id this action is a part of.

CharSequence getDescription()

Returns the description of this action.

int getDescriptionEditInputType()

Returns InputType of action description in editing; only valid when isDescriptionEditable() is true.

int getDescriptionInputType()

Returns InputType of action description not in editing.

CharSequence getEditDescription()

Returns the optional description text to edit.

int getEditInputType()

Returns InputType of action title in editing; only valid when isEditable() is true.

CharSequence getEditTitle()

Returns the optional title text to edit.

int getInputType()

Returns InputType of action title not in editing.

Intent getIntent()

Returns the intent associated with this action.

List<GuidedAction> getSubActions()
CharSequence getTitle()

Returns the title of this action.

boolean hasEditableActivatorView()

Returns whether this action can be activated to edit, e.g.

boolean hasMultilineDescription()

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 hasSubActions()
boolean hasTextEditable()

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 isAutoSaveRestoreEnabled()

Returns true if Action will be saved to instanceState and restored later, false otherwise.

boolean isChecked()

Returns whether this action is checked.

boolean isDescriptionEditable()

Returns whether this action description is editable.

boolean isEditTitleUsed()

Returns true if getEditTitle() is not null.

boolean isEditable()

Returns whether this action title is editable.

boolean isEnabled()

Returns whether this action is enabled.

boolean isFocusable()

Returns whether this action is focusable.

void onRestoreInstanceState(Bundle bundle, String key)

Restore action from a bundle using a given key.

void onSaveInstanceState(Bundle bundle, String key)

Save action into a bundle using a given key.

void setChecked(boolean checked)

Sets whether this action is checked.

void setDescription(CharSequence description)

Sets the description of this action.

void setEditDescription(CharSequence editDescription)

Sets the optional description text to edit instead of setDescription(CharSequence).

void setEditTitle(CharSequence editTitle)

Sets the optional title text to edit instead of setTitle(CharSequence).

void setEnabled(boolean enabled)

Sets whether this action is enabled.

void setFocusable(boolean focusable)

Sets whether this action is focusable.

void setIntent(Intent intent)

Sets the intent of this action.

void setSubActions(List<GuidedAction> actions)

Change sub actions list.

void setTitle(CharSequence title)

Sets the title of this action.

Inherited methods

From class android.support.v17.leanback.widget.Action
From class java.lang.Object

Constants

ACTION_ID_CANCEL

added in version 24.1.0
long ACTION_ID_CANCEL

Id of standard Cancel action.

Constant Value: -5 (0xfffffffffffffffb)

ACTION_ID_CONTINUE

added in version 24.1.0
long ACTION_ID_CONTINUE

Id of standard Finish action.

Constant Value: -7 (0xfffffffffffffff9)

ACTION_ID_CURRENT

added in version 24.1.0
long ACTION_ID_CURRENT

When finishing editing, stay on current action.

Constant Value: -3 (0xfffffffffffffffd)

ACTION_ID_FINISH

added in version 24.1.0
long ACTION_ID_FINISH

Id of standard Finish action.

Constant Value: -6 (0xfffffffffffffffa)

ACTION_ID_NEXT

added in version 24.1.0
long ACTION_ID_NEXT

When finishing editing, goes to next action.

Constant Value: -2 (0xfffffffffffffffe)

ACTION_ID_NO

added in version 24.1.0
long ACTION_ID_NO

Id of standard No action.

Constant Value: -9 (0xfffffffffffffff7)

ACTION_ID_OK

added in version 24.1.0
long ACTION_ID_OK

Id of standard OK action.

Constant Value: -4 (0xfffffffffffffffc)

ACTION_ID_YES

added in version 24.1.0
long ACTION_ID_YES

Id of standard Yes action.

Constant Value: -8 (0xfffffffffffffff8)

CHECKBOX_CHECK_SET_ID

added in version 24.1.0
int CHECKBOX_CHECK_SET_ID

Checkset Id for checkbox.

Constant Value: -1 (0xffffffff)

DEFAULT_CHECK_SET_ID

added in version 22.1.0
int DEFAULT_CHECK_SET_ID

Default checkset Id for radio.

Constant Value: 1 (0x00000001)

NO_CHECK_SET

added in version 22.1.0
int NO_CHECK_SET

Special check set Id that is neither checkbox nor radio.

Constant Value: 0 (0x00000000)

Protected constructors

GuidedAction

added in version 24.1.0
GuidedAction ()

Public methods

getCheckSetId

added in version 22.1.0
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 CHECKBOX_CHECK_SET_ID if this is a checkbox, or NO_CHECK_SET if this action is not a checkbox or radiobutton.

getDescription

added in version 22.1.0
CharSequence getDescription ()

Returns the description of this action.

Returns
CharSequence The description of this action.

getDescriptionEditInputType

added in version 24.1.0
int getDescriptionEditInputType ()

Returns InputType of action description in editing; only valid when isDescriptionEditable() is true.

Returns
int InputType of action description in editing.

getDescriptionInputType

added in version 24.1.0
int getDescriptionInputType ()

Returns InputType of action description not in editing.

Returns
int InputType of action description not in editing.

getEditDescription

added in version 24.1.0
CharSequence getEditDescription ()

Returns the optional description text to edit. When not null, it is being edited instead of getDescription().

Returns
CharSequence Optional description text to edit instead of getDescription().

getEditInputType

added in version 24.1.0
int getEditInputType ()

Returns InputType of action title in editing; only valid when isEditable() is true.

Returns
int InputType of action title in editing.

getEditTitle

added in version 24.1.0
CharSequence getEditTitle ()

Returns the optional title text to edit. When not null, it is being edited instead of getTitle().

Returns
CharSequence Optional title text to edit instead of getTitle().

getInputType

added in version 24.1.0
int getInputType ()

Returns InputType of action title not in editing.

Returns
int InputType of action title not in editing.

getIntent

added in version 22.1.0
Intent getIntent ()

Returns the intent associated with this action.

Returns
Intent The intent set when this action was built.

getSubActions

added in version 24.1.0
List<GuidedAction> getSubActions ()

Returns
List<GuidedAction> List of sub actions or null if sub actions list is not enabled.

getTitle

added in version 22.1.0
CharSequence getTitle ()

Returns the title of this action.

Returns
CharSequence The title set when this action was built.

hasEditableActivatorView

added in version 24.1.0
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

added in version 22.1.0
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

added in version 22.1.0
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

added in version 24.1.0
boolean hasSubActions ()

Returns
boolean True if has sub actions list, even it's currently empty.

hasTextEditable

added in version 24.1.0
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

added in version 22.1.0
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

added in version 24.1.0
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:

  • isEditable() is true: save text of getTitle()
  • isDescriptionEditable() is true: save text of getDescription()
  • getCheckSetId() is not NO_CHECK_SET: save isChecked()}
  • GuidedDatePickerAction will be saved
  • App may explicitly disable auto restore and handle by itself. App should override Fragment onSaveInstanceState() and onCreateActions()

    Returns
    boolean True if Action will be saved to instanceState and restored later, false otherwise.

    isChecked

    added in version 22.1.0
    boolean isChecked ()

    Returns whether this action is checked.

    Returns
    boolean true if the action is currently checked, false otherwise.

    isDescriptionEditable

    added in version 24.1.0
    boolean isDescriptionEditable ()

    Returns whether this action description is editable.

    Returns
    boolean true if the action description is editable, false otherwise.

    isEditTitleUsed

    added in version 24.1.0
    boolean isEditTitleUsed ()

    Returns true if getEditTitle() is not null. When true, the getEditTitle() is being edited instead of getTitle().

    Returns
    boolean true if getEditTitle() is not null.

    isEditable

    added in version 24.1.0
    boolean isEditable ()

    Returns whether this action title is editable.

    Returns
    boolean true if the action title is editable, false otherwise.

    isEnabled

    added in version 22.1.0
    boolean isEnabled ()

    Returns whether this action is enabled.

    Returns
    boolean true if the action is currently enabled, false otherwise.

    isFocusable

    added in version 24.1.0
    boolean isFocusable ()

    Returns whether this action is focusable.

    Returns
    boolean true if the action is currently focusable, false otherwise.

    onRestoreInstanceState

    added in version 24.1.0
    void onRestoreInstanceState (Bundle bundle, 
                    String key)

    Restore action from a bundle using a given key. When isAutoRestore() is true:

  • isEditable() is true: save text of getTitle()
  • isDescriptionEditable() is true: save text of getDescription()
  • getCheckSetId() is not NO_CHECK_SET: save isChecked()}
  • GuidedDatePickerAction will be saved
  • Subclass may override this method.

    Parameters
    bundle Bundle: Bundle to restore the Action from.

    key String: Key used to restore the Action.

    onSaveInstanceState

    added in version 24.1.0
    void onSaveInstanceState (Bundle bundle, 
                    String key)

    Save action into a bundle using a given key. When isAutoRestoreEna() is true:

  • isEditable() is true: save text of getTitle()
  • isDescriptionEditable() is true: save text of getDescription()
  • getCheckSetId() is not NO_CHECK_SET: save isChecked()}
  • GuidedDatePickerAction will be saved
  • Subclass may override this method.

    Parameters
    bundle Bundle: Bundle to save the Action.

    key String: Key used to save the Action.

    setChecked

    added in version 22.1.0
    void setChecked (boolean checked)

    Sets whether this action is checked.

    Parameters
    checked boolean: Whether this action should be checked.

    setDescription

    added in version 24.1.0
    void setDescription (CharSequence description)

    Sets the description of this action.

    Parameters
    description CharSequence: The description of the action.

    setEditDescription

    added in version 24.1.0
    void setEditDescription (CharSequence editDescription)

    Sets the optional description text to edit instead of setDescription(CharSequence).

    Parameters
    editDescription CharSequence: Optional description text to edit instead of setDescription(CharSequence).

    setEditTitle

    added in version 24.1.0
    void setEditTitle (CharSequence editTitle)

    Sets the optional title text to edit instead of setTitle(CharSequence).

    Parameters
    editTitle CharSequence: Optional title text to edit instead of setTitle(CharSequence).

    setEnabled

    added in version 22.1.0
    void setEnabled (boolean enabled)

    Sets whether this action is enabled.

    Parameters
    enabled boolean: Whether this action should be enabled.

    setFocusable

    added in version 24.1.0
    void setFocusable (boolean focusable)

    Sets whether this action is focusable.

    Parameters
    focusable boolean: Whether this action should be focusable.

    setIntent

    added in version 24.1.0
    void setIntent (Intent intent)

    Sets the intent of this action.

    Parameters
    intent Intent: New intent to set on this action.

    setSubActions

    added in version 24.1.0
    void setSubActions (List<GuidedAction> actions)

    Change sub actions list.

    Parameters
    actions List: Sub actions list to set on this action. Sets null to disable sub actions.

    setTitle

    added in version 24.1.0
    void setTitle (CharSequence title)

    Sets the title of this action.

    Parameters
    title CharSequence: The title set when this action was built.