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
abstract

Base builder class to build a GuidedAction object.

open

Builds a GuidedAction object.

Constants
static Int

Special check set Id that is neither checkbox nor radio.

static Int

Default checkset Id for radio.

static Int

Checkset Id for checkbox.

static Long

When finishing editing, goes to next action.

static Long

When finishing editing, stay on current action.

static Long

Id of standard OK action.

static Long

Id of standard Cancel action.

static Long

Id of standard Finish action.

static Long

Id of standard Finish action.

static Long

Id of standard Yes action.

static Long

Id of standard No action.

Inherited constants
Protected constructors

Public methods
open Unit
setEditDescription(editDescription: CharSequence!)

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

open Array<String!>!

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

open Boolean

Returns whether this action title is editable.

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

Save action into a bundle using a given key.

open Boolean

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

open Boolean

open CharSequence!

Returns the optional description text to edit.

open Unit
setEnabled(enabled: Boolean)

Sets whether this action is enabled.

open Unit

Sets the title of this action.

open Boolean

Returns if this action has editable title or editable description.

open Unit
setChecked(checked: Boolean)

Sets whether this action is checked.

open CharSequence!

Returns the description of this action.

open CharSequence!

Returns the title of this action.

open Int

Returns InputType of action title not in editing.

open Boolean

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

open Unit

Change sub actions list.

open Int

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

open Intent!

Returns the intent associated with this action.

open Unit

Sets the description of this action.

open Boolean

Returns whether this action is enabled.

open CharSequence!

Returns the optional title text to edit.

open Boolean

Returns whether this action is focusable.

open MutableList<GuidedAction!>!

open Boolean

Returns true if getEditTitle() is not null.

open Boolean

Returns whether this action is has a multiline description.

open Boolean

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

open Int

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

open Unit

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

open Boolean

Returns whether this action is checked.

open Unit
setIntent(intent: Intent!)

Sets the intent of this action.

open Int

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

Boolean

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

open Int

Returns InputType of action description not in editing.

open Unit

Restore action from a bundle using a given key.

open Boolean

Returns whether this action description is editable.

open Unit
setFocusable(focusable: Boolean)

Sets whether this action is focusable.

Inherited functions

Constants

NO_CHECK_SET

static val NO_CHECK_SET: Int

Special check set Id that is neither checkbox nor radio.

Value: 0

DEFAULT_CHECK_SET_ID

static val DEFAULT_CHECK_SET_ID: Int

Default checkset Id for radio.

Value: 1

CHECKBOX_CHECK_SET_ID

static val CHECKBOX_CHECK_SET_ID: Int

Checkset Id for checkbox.

Value: -1

ACTION_ID_NEXT

static val ACTION_ID_NEXT: Long

When finishing editing, goes to next action.

Value: -2

ACTION_ID_CURRENT

static val ACTION_ID_CURRENT: Long

When finishing editing, stay on current action.

Value: -3

ACTION_ID_OK

static val ACTION_ID_OK: Long

Id of standard OK action.

Value: -4

ACTION_ID_CANCEL

static val ACTION_ID_CANCEL: Long

Id of standard Cancel action.

Value: -5

ACTION_ID_FINISH

static val ACTION_ID_FINISH: Long

Id of standard Finish action.

Value: -6

ACTION_ID_CONTINUE

static val ACTION_ID_CONTINUE: Long

Id of standard Finish action.

Value: -7

ACTION_ID_YES

static val ACTION_ID_YES: Long

Id of standard Yes action.

Value: -8

ACTION_ID_NO

static val ACTION_ID_NO: Long

Id of standard No action.

Value: -9

Protected constructors

<init>

protected GuidedAction()

Public methods

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

getAutofillHints

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

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

isEditable

open fun isEditable(): Boolean

Returns whether this action title is editable.

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

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.

    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.

    hasSubActions

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

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

    setEnabled

    open fun setEnabled(enabled: Boolean): Unit

    Sets whether this action is enabled.

    Parameters
    enabled Boolean: Whether this action should be enabled.

    setTitle

    open fun setTitle(title: CharSequence!): Unit

    Sets the title of this action.

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

    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.

    setChecked

    open fun setChecked(checked: Boolean): Unit

    Sets whether this action is checked.

    Parameters
    checked Boolean: Whether this action should be checked.

    getDescription

    open fun getDescription(): CharSequence!

    Returns the description of this action.

    Return
    CharSequence!: The description of this action.

    getTitle

    open fun getTitle(): CharSequence!

    Returns the title of this action.

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

    getInputType

    open fun getInputType(): Int

    Returns InputType of action title not in editing.

    Return
    Int: InputType of action title not in editing.

    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.

    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.

    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.

    getIntent

    open fun getIntent(): Intent!

    Returns the intent associated with this action.

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

    setDescription

    open fun setDescription(description: CharSequence!): Unit

    Sets the description of this action.

    Parameters
    description CharSequence!: The description of the action.

    isEnabled

    open fun isEnabled(): Boolean

    Returns whether this action is enabled.

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

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

    isFocusable

    open fun isFocusable(): Boolean

    Returns whether this action is focusable.

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

    getSubActions

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

    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.

    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.

    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.

    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.

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

    isChecked

    open fun isChecked(): Boolean

    Returns whether this action is checked.

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

    setIntent

    open fun setIntent(intent: Intent!): Unit

    Sets the intent of this action.

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

    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.

    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.

    getDescriptionInputType

    open fun getDescriptionInputType(): Int

    Returns InputType of action description not in editing.

    Return
    Int: InputType of action description not in editing.

    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.

    isDescriptionEditable

    open fun isDescriptionEditable(): Boolean

    Returns whether this action description is editable.

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

    setFocusable

    open fun setFocusable(focusable: Boolean): Unit

    Sets whether this action is focusable.

    Parameters
    focusable Boolean: Whether this action should be focusable.