GuidedAction


class GuidedAction : Action

Known direct subclasses
GuidedDatePickerAction

Subclass of GuidedAction that can choose a date.


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

Summary

Nested types

Builds a GuidedAction object.

Base builder class to build a GuidedAction object.

Constants

const Long

Id of standard Cancel action.

const Long

Id of standard Finish action.

const Long

When finishing editing, stay on current action.

const Long

Id of standard Finish action.

const Long

When finishing editing, goes to next action.

const Long

Id of standard No action.

const Long

Id of standard OK action.

const Long

Id of standard Yes action.

const Int

Checkset Id for checkbox.

const Int

Default checkset Id for radio.

const Int

Special check set Id that is neither checkbox nor radio.

Protected constructors

Public functions

Array<String!>!

Returns autofill hints, see setAutofillHints.

Int

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

CharSequence?

Returns the description of this action.

Int

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

Int

Returns InputType of action description not in editing.

CharSequence?

Returns the optional description text to edit.

Int

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

CharSequence?

Returns the optional title text to edit.

Int

Returns InputType of action title not in editing.

Intent?

Returns the intent associated with this action.

(Mutable)List<GuidedAction!>?
CharSequence?

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

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

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.

Boolean

Returns whether this action is checked.

Boolean

Returns whether this action description is editable.

Boolean

Returns true if getEditTitle is not null.

Boolean

Returns whether this action title is editable.

Boolean

Returns whether this action is enabled.

Boolean

Returns whether this action is focusable.

Unit

Restore action from a bundle using a given key.

Unit

Save action into a bundle using a given key.

Unit
setChecked(checked: Boolean)

Sets whether this action is checked.

Unit

Sets the description of this action.

Unit
setEditDescription(editDescription: CharSequence?)

Sets the optional description text to edit instead of setDescription.

Unit

Sets the optional title text to edit instead of setTitle.

Unit
setEnabled(enabled: Boolean)

Sets whether this action is enabled.

Unit
setFocusable(focusable: Boolean)

Sets whether this action is focusable.

Unit
setIntent(intent: Intent?)

Sets the intent of this action.

Unit

Change sub actions list.

Unit

Sets the title of this action.

Inherited Constants

From androidx.leanback.widget.Action
const Long
NO_ID = -1

Indicates that an id has not been set.

Inherited functions

From androidx.leanback.widget.Action
Unit
addKeyCode(keyCode: Int)

Adds a keycode used to invoke this Action.

Drawable?

Returns the icon drawable for this Action.

Long

Returns the id for this Action.

CharSequence?

Returns the first line label for this Action.

CharSequence?

Returns the second line label for this Action.

Unit
removeKeyCode(keyCode: Int)

Removes a keycode used to invoke this Action.

Boolean

Returns true if the Action should respond to the given keycode.

Unit
setIcon(icon: Drawable?)

Sets the icon drawable for this Action.

Unit
setId(id: Long)

Sets the id for this Action.

Unit

Sets the first line label for this Action.

Unit

Sets the second line label for this Action.

String

Constants

ACTION_ID_CANCEL

Added in 1.1.0
const val ACTION_ID_CANCEL = -5: Long

Id of standard Cancel action.

ACTION_ID_CONTINUE

Added in 1.1.0
const val ACTION_ID_CONTINUE = -7: Long

Id of standard Finish action.

ACTION_ID_CURRENT

Added in 1.1.0
const val ACTION_ID_CURRENT = -3: Long

When finishing editing, stay on current action.

ACTION_ID_FINISH

Added in 1.1.0
const val ACTION_ID_FINISH = -6: Long

Id of standard Finish action.

ACTION_ID_NEXT

Added in 1.1.0
const val ACTION_ID_NEXT = -2: Long

When finishing editing, goes to next action.

ACTION_ID_NO

Added in 1.1.0
const val ACTION_ID_NO = -9: Long

Id of standard No action.

ACTION_ID_OK

Added in 1.1.0
const val ACTION_ID_OK = -4: Long

Id of standard OK action.

ACTION_ID_YES

Added in 1.1.0
const val ACTION_ID_YES = -8: Long

Id of standard Yes action.

CHECKBOX_CHECK_SET_ID

Added in 1.1.0
const val CHECKBOX_CHECK_SET_ID = -1: Int

Checkset Id for checkbox.

DEFAULT_CHECK_SET_ID

Added in 1.1.0
const val DEFAULT_CHECK_SET_ID = 1: Int

Default checkset Id for radio.

NO_CHECK_SET

Added in 1.1.0
const val NO_CHECK_SET = 0: Int

Special check set Id that is neither checkbox nor radio.

Protected constructors

GuidedAction

Added in 1.1.0
protected GuidedAction()

Public functions

getAutofillHints

Added in 1.1.0
fun getAutofillHints(): Array<String!>!

Returns autofill hints, see setAutofillHints.

getCheckSetId

Added in 1.1.0
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.

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 1.1.0
fun getDescription(): CharSequence?

Returns the description of this action.

Returns
CharSequence?

The description of this action.

getDescriptionEditInputType

Added in 1.1.0
fun getDescriptionEditInputType(): Int

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

Returns
Int

InputType of action description in editing.

getDescriptionInputType

Added in 1.1.0
fun getDescriptionInputType(): Int

Returns InputType of action description not in editing.

Returns
Int

InputType of action description not in editing.

getEditDescription

Added in 1.1.0
fun getEditDescription(): CharSequence?

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 1.1.0
fun getEditInputType(): Int

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

Returns
Int

InputType of action title in editing.

getEditTitle

Added in 1.1.0
fun getEditTitle(): CharSequence?

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 1.1.0
fun getInputType(): Int

Returns InputType of action title not in editing.

Returns
Int

InputType of action title not in editing.

getIntent

Added in 1.1.0
fun getIntent(): Intent?

Returns the intent associated with this action.

Returns
Intent?

The intent set when this action was built.

getSubActions

Added in 1.1.0
fun getSubActions(): (Mutable)List<GuidedAction!>?
Returns
(Mutable)List<GuidedAction!>?

List of sub actions or null if sub actions list is not enabled.

getTitle

Added in 1.1.0
fun getTitle(): CharSequence?

Returns the title of this action.

Returns
CharSequence?

The title set when this action was built.

hasEditableActivatorView

Added in 1.1.0
fun hasEditableActivatorView(): Boolean

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 1.1.0
fun hasMultilineDescription(): Boolean

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

Returns
Boolean

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

hasSubActions

Added in 1.1.0
fun hasSubActions(): Boolean
Returns
Boolean

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

hasTextEditable

Added in 1.1.0
fun hasTextEditable(): Boolean

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

Returns
Boolean

true if will only display information, false otherwise.

isAutoSaveRestoreEnabled

Added in 1.1.0
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:

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 1.1.0
fun isChecked(): Boolean

Returns whether this action is checked.

Returns
Boolean

true if the action is currently checked, false otherwise.

isDescriptionEditable

Added in 1.1.0
fun isDescriptionEditable(): Boolean

Returns whether this action description is editable.

Returns
Boolean

true if the action description is editable, false otherwise.

isEditTitleUsed

Added in 1.1.0
fun isEditTitleUsed(): Boolean

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 1.1.0
fun isEditable(): Boolean

Returns whether this action title is editable.

Returns
Boolean

true if the action title is editable, false otherwise.

isEnabled

Added in 1.1.0
fun isEnabled(): Boolean

Returns whether this action is enabled.

Returns
Boolean

true if the action is currently enabled, false otherwise.

isFocusable

Added in 1.1.0
fun isFocusable(): Boolean

Returns whether this action is focusable.

Returns
Boolean

true if the action is currently focusable, false otherwise.

onRestoreInstanceState

Added in 1.1.0
fun onRestoreInstanceState(bundle: Bundle, key: String): Unit

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

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 1.1.0
fun onSaveInstanceState(bundle: Bundle, key: String): Unit

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

Subclass may override this method.
Parameters
bundle: Bundle

Bundle to save the Action.

key: String

Key used to save the Action.

setChecked

Added in 1.1.0
fun setChecked(checked: Boolean): Unit

Sets whether this action is checked.

Parameters
checked: Boolean

Whether this action should be checked.

setDescription

Added in 1.1.0
fun setDescription(description: CharSequence?): Unit

Sets the description of this action.

Parameters
description: CharSequence?

The description of the action.

setEditDescription

Added in 1.1.0
fun setEditDescription(editDescription: CharSequence?): Unit

Sets the optional description text to edit instead of setDescription.

Parameters
editDescription: CharSequence?

Optional description text to edit instead of setDescription.

setEditTitle

Added in 1.1.0
fun setEditTitle(editTitle: CharSequence?): Unit

Sets the optional title text to edit instead of setTitle.

Parameters
editTitle: CharSequence?

Optional title text to edit instead of setTitle.

setEnabled

Added in 1.1.0
fun setEnabled(enabled: Boolean): Unit

Sets whether this action is enabled.

Parameters
enabled: Boolean

Whether this action should be enabled.

setFocusable

Added in 1.1.0
fun setFocusable(focusable: Boolean): Unit

Sets whether this action is focusable.

Parameters
focusable: Boolean

Whether this action should be focusable.

setIntent

Added in 1.1.0
fun setIntent(intent: Intent?): Unit

Sets the intent of this action.

Parameters
intent: Intent?

New intent to set on this action.

setSubActions

Added in 1.1.0
fun setSubActions(actions: (Mutable)List<GuidedAction!>?): Unit

Change sub actions list.

Parameters
actions: (Mutable)List<GuidedAction!>?

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

setTitle

Added in 1.1.0
fun setTitle(title: CharSequence?): Unit

Sets the title of this action.

Parameters
title: CharSequence?

The title set when this action was built.