Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

GuidedAction

open class GuidedAction : Action
kotlin.Any
   ↳ androidx.leanback.widget.Action
   ↳ androidx.leanback.widget.GuidedAction

A data class which represents an action within a . 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 BuilderBase#applyValues(GuidedAction).

Summary

Nested classes

open

Builds a GuidedAction object.

abstract

Base builder class to build a GuidedAction object.

Constants

static Long

Id of standard Cancel action.

static Long

Id of standard Finish action.

static Long

When finishing editing, stay on current action.

static Long

Id of standard Finish action.

static Long

When finishing editing, goes to next action.

static Long

Id of standard No action.

static Long

Id of standard OK action.

static Long

Id of standard Yes action.

static Int

Checkset Id for checkbox.

static Int

Default checkset Id for radio.

static Int

Special check set Id that is neither checkbox nor radio.

Inherited constants

Protected constructors

Public methods

open Array<String!>!

Returns autofill hints, see android.view.View#setAutofillHints(String...).

open Int

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

open CharSequence!

Returns the description of this action.

open Int

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

open Int

Returns InputType of action description not in editing.

open CharSequence!

Returns the optional description text to edit.

open Int

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

open CharSequence!

Returns the optional title text to edit.

open Int

Returns InputType of action title not in editing.

open Intent!

Returns the intent associated with this action.

open MutableList<GuidedAction!>!

open CharSequence!

Returns the title of this action.

open Boolean

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

open Boolean

Returns whether this action is has a multiline description.

open Boolean

Returns whether this action will request further user input when selected, such as showing another GuidedStepFragment or launching a new activity.

open Boolean

open Boolean

Returns if this action has editable title or editable description.

open Boolean

Returns whether the action will only display information and is thus not clickable.

Boolean

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

open Boolean

Returns whether this action is checked.

open Boolean

Returns whether this action description is editable.

open Boolean

Returns true if getEditTitle() is not null.

open Boolean

Returns whether this action title is editable.

open Boolean

Returns whether this action is enabled.

open Boolean

Returns whether this action is focusable.

open Unit

Restore action from a bundle using a given key.

open Unit
onSaveInstanceState(bundle: Bundle!, key: String!)

Save action into a bundle using a given key.

open Unit
setChecked(checked: Boolean)

Sets whether this action is checked.

open Unit

Sets the description of this action.

open Unit
setEditDescription(editDescription: CharSequence!)

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

open Unit

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

open Unit
setEnabled(enabled: Boolean)

Sets whether this action is enabled.

open Unit
setFocusable(focusable: Boolean)

Sets whether this action is focusable.

open Unit
setIntent(intent: Intent!)

Sets the intent of this action.

open Unit

Change sub actions list.

open Unit

Sets the title of this action.

Inherited functions

Constants

ACTION_ID_CANCEL

static val ACTION_ID_CANCEL: Long

Id of standard Cancel action.

Value: -5

ACTION_ID_CONTINUE

static val ACTION_ID_CONTINUE: Long

Id of standard Finish action.

Value: -7

ACTION_ID_CURRENT

static val ACTION_ID_CURRENT: Long

When finishing editing, stay on current action.

Value: -3

ACTION_ID_FINISH

static val ACTION_ID_FINISH: Long

Id of standard Finish action.

Value: -6

ACTION_ID_NEXT

static val ACTION_ID_NEXT: Long

When finishing editing, goes to next action.

Value: -2

ACTION_ID_NO

static val ACTION_ID_NO: Long

Id of standard No action.

Value: -9

ACTION_ID_OK

static val ACTION_ID_OK: Long

Id of standard OK action.

Value: -4

ACTION_ID_YES

static val ACTION_ID_YES: Long

Id of standard Yes action.

Value: -8

CHECKBOX_CHECK_SET_ID

static val CHECKBOX_CHECK_SET_ID: Int

Checkset Id for checkbox.

Value: -1

DEFAULT_CHECK_SET_ID

static val DEFAULT_CHECK_SET_ID: Int

Default checkset Id for radio.

Value: 1

NO_CHECK_SET

static val NO_CHECK_SET: Int

Special check set Id that is neither checkbox nor radio.

Value: 0

Protected constructors

<init>

protected GuidedAction()

Public methods

getAutofillHints

open fun getAutofillHints(): Array<String!>!

Returns autofill hints, see android.view.View#setAutofillHints(String...).

getCheckSetId

open fun getCheckSetId(): Int

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.

Return
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

open fun getDescription(): CharSequence!

Returns the description of this action.

Return
CharSequence!: The description of this action.

getDescriptionEditInputType

open fun getDescriptionEditInputType(): Int

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

Return
Int: InputType of action description in editing.

getDescriptionInputType

open fun getDescriptionInputType(): Int

Returns InputType of action description not in editing.

Return
Int: InputType of action description not in editing.

getEditDescription

open fun getEditDescription(): CharSequence!

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

Return
CharSequence!: Optional description text to edit instead of getDescription().

getEditInputType

open fun getEditInputType(): Int

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

Return
Int: InputType of action title in editing.

getEditTitle

open fun getEditTitle(): CharSequence!

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

Return
CharSequence!: Optional title text to edit instead of getTitle().

getInputType

open fun getInputType(): Int

Returns InputType of action title not in editing.

Return
Int: InputType of action title not in editing.

getIntent

open fun getIntent(): Intent!

Returns the intent associated with this action.

Return
Intent!: The intent set when this action was built.

getSubActions

open fun getSubActions(): MutableList<GuidedAction!>!
Return
MutableList<GuidedAction!>!: List of sub actions or null if sub actions list is not enabled.

getTitle

open fun getTitle(): CharSequence!

Returns the title of this action.

Return
CharSequence!: The title set when this action was built.

hasEditableActivatorView

open fun hasEditableActivatorView(): Boolean

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

Return
Boolean: true if the action can be activated to edit.

hasMultilineDescription

open fun hasMultilineDescription(): Boolean

Returns whether this action is has a multiline description.

Return
Boolean: true if the action was constructed as having a multiline description, false otherwise.

hasNext

open fun hasNext(): Boolean

Returns whether this action will request further user input when selected, such as showing another GuidedStepFragment or launching a new activity. Configured during construction.

Return
Boolean: true if the action will request further user input when selected, false otherwise.

hasSubActions

open fun hasSubActions(): Boolean
Return
Boolean: True if has sub actions list, even it's currently empty.

hasTextEditable

open fun hasTextEditable(): Boolean

Returns if this action has editable title or editable description.

Return
Boolean: True if this action has editable title or editable description, false otherwise.

infoOnly

open fun infoOnly(): Boolean

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.

Return
Boolean: true if will only display information, false otherwise.

isAutoSaveRestoreEnabled

fun isAutoSaveRestoreEnabled(): Boolean

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

    Return
    Boolean: True if Action will be saved to instanceState and restored later, false otherwise.

    isChecked

    open fun isChecked(): Boolean

    Returns whether this action is checked.

    Return
    Boolean: true if the action is currently checked, false otherwise.

    isDescriptionEditable

    open fun isDescriptionEditable(): Boolean

    Returns whether this action description is editable.

    Return
    Boolean: true if the action description is editable, false otherwise.

    isEditTitleUsed

    open fun isEditTitleUsed(): Boolean

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

    Return
    Boolean: true if getEditTitle() is not null.

    isEditable

    open fun isEditable(): Boolean

    Returns whether this action title is editable.

    Return
    Boolean: true if the action title is editable, false otherwise.

    isEnabled

    open fun isEnabled(): Boolean

    Returns whether this action is enabled.

    Return
    Boolean: true if the action is currently enabled, false otherwise.

    isFocusable

    open fun isFocusable(): Boolean

    Returns whether this action is focusable.

    Return
    Boolean: true if the action is currently focusable, false otherwise.

    onRestoreInstanceState

    open fun onRestoreInstanceState(bundle: Bundle!, key: String!): Unit

    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 Bundle!: Key used to restore the Action.

    onSaveInstanceState

    open fun onSaveInstanceState(bundle: Bundle!, key: String!): Unit

    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 Bundle!: Key used to save the Action.

    setChecked

    open fun setChecked(checked: Boolean): Unit

    Sets whether this action is checked.

    Parameters
    checked Boolean: Whether this action should be checked.

    setDescription

    open fun setDescription(description: CharSequence!): Unit

    Sets the description of this action.

    Parameters
    description CharSequence!: The description of the action.

    setEditDescription

    open fun setEditDescription(editDescription: CharSequence!): Unit

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

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

    setEditTitle

    open fun setEditTitle(editTitle: CharSequence!): Unit

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

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

    setEnabled

    open fun setEnabled(enabled: Boolean): Unit

    Sets whether this action is enabled.

    Parameters
    enabled Boolean: Whether this action should be enabled.

    setFocusable

    open fun setFocusable(focusable: Boolean): Unit

    Sets whether this action is focusable.

    Parameters
    focusable Boolean: Whether this action should be focusable.

    setIntent

    open fun setIntent(intent: Intent!): Unit

    Sets the intent of this action.

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

    setSubActions

    open fun setSubActions(actions: MutableList<GuidedAction!>!): Unit

    Change sub actions list.

    Parameters
    actions MutableList<GuidedAction!>!: Sub actions list to set on this action. Sets null to disable sub actions.

    setTitle

    open fun setTitle(title: CharSequence!): Unit

    Sets the title of this action.

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