Google is committed to advancing racial equity for Black communities. See how.

GuidedActionsStylist

open class GuidedActionsStylist : FragmentAnimationProvider
kotlin.Any
   ↳ androidx.leanback.widget.GuidedActionsStylist

GuidedActionsStylist is used within a androidx.leanback.app.GuidedStepFragment to supply the right-side panel where users can take actions. It consists of a container for the list of actions, and a stationary selector view that indicates visually the location of focus. GuidedActionsStylist has two different layouts: default is for normal actions including text, radio, checkbox, DatePicker, etc, the other when setAsButtonActions() is called is recommended for button actions such as "yes", "no".

Many aspects of the base GuidedActionsStylist can be customized through theming; see the theme attributes below. Note that these attributes are not set on individual elements in layout XML, but instead would be set in a custom theme. See Styles and Themes for more information.

If these hooks are insufficient, this class may also be subclassed. Subclasses may wish to override the onProvideLayoutId method to change the layout used to display the list container and selector; override onProvideItemLayoutId(int) and getItemViewType(GuidedAction) method to change the layout used to display each action.

To support a "click to activate" view similar to DatePicker, app needs:

  • Override onProvideItemLayoutId(int) and getItemViewType(GuidedAction), provides a layout id for the action.
  • The layout must include a widget with id "guidedactions_activator_item", the widget is toggled edit mode by View#setActivated(boolean).
  • Override onBindActivatorView(ViewHolder, GuidedAction) to populate values into View.
  • Override onUpdateActivatorView(ViewHolder, GuidedAction) to update action.

    Note: If an alternate list layout is provided, the following view IDs must be supplied:

    These view IDs must be present in order for the stylist to function. The list ID must correspond to a VerticalGridView or subclass.

    If an alternate item layout is provided, the following view IDs should be used to refer to base elements:

    These view IDs are allowed to be missing, in which case the corresponding views in will be null.

    In order to support editable actions, the view associated with guidedactions_item_title should be a subclass of android.widget.EditText, and should satisfy the interface and GuidedActionAutofillSupport interface. androidx.leanback.R.attr#guidedStepImeAppearingAnimation androidx.leanback.R.attr#guidedStepImeDisappearingAnimation androidx.leanback.R.attr#guidedActionsSelectorDrawable androidx.leanback.R.attr#guidedActionsListStyle androidx.leanback.R.attr#guidedSubActionsListStyle androidx.leanback.R.attr#guidedButtonActionsListStyle androidx.leanback.R.attr#guidedActionItemContainerStyle androidx.leanback.R.attr#guidedActionItemCheckmarkStyle androidx.leanback.R.attr#guidedActionItemIconStyle androidx.leanback.R.attr#guidedActionItemContentStyle androidx.leanback.R.attr#guidedActionItemTitleStyle androidx.leanback.R.attr#guidedActionItemDescriptionStyle androidx.leanback.R.attr#guidedActionItemChevronStyle androidx.leanback.R.attr#guidedActionPressedAnimation androidx.leanback.R.attr#guidedActionUnpressedAnimation androidx.leanback.R.attr#guidedActionEnabledChevronAlpha androidx.leanback.R.attr#guidedActionDisabledChevronAlpha androidx.leanback.R.attr#guidedActionTitleMinLines androidx.leanback.R.attr#guidedActionTitleMaxLines androidx.leanback.R.attr#guidedActionDescriptionMinLines androidx.leanback.R.attr#guidedActionVerticalPadding

  • Summary

    Nested classes
    open

    ViewHolder caches information about the action item layouts' subviews.

    Constants
    static Int

    ViewType for DatePicker.

    static Int

    Default viewType that associated with default layout Id for the action item.

    Public constructors

    GuidedActionsStylist is used within a androidx.leanback.app.GuidedStepFragment to supply the right-side panel where users can take actions.

    Public methods
    open Unit
    collapseAction(withTransition: Boolean)

    Collapse expanded action.

    open Unit
    expandAction(action: GuidedAction!, withTransition: Boolean)

    Expand an action.

    open VerticalGridView!

    Returns the VerticalGridView that displays the list of GuidedActions.

    open GuidedAction!

    open Int

    Return view type of action, each different type can have differently associated layout Id.

    open VerticalGridView!

    Returns the VerticalGridView that displays the sub actions list of an expanded action.

    Boolean

    Boolean

    open Boolean

    Returns true if it is button actions list, false for normal actions list.

    open Boolean

    Returns if expand/collapse animation is supported.

    open Boolean

    open Boolean

    Returns true if it is running an expanding or collapsing transition, false otherwise.

    open Boolean

    open Unit

    Animates the view holder's view (or subviews thereof) when the action has had its check state changed.

    open Unit

    Animates the view holder's view (or subviews thereof) when the action has had its focus state changed.

    open Unit

    Animates the view holder's view (or subviews thereof) when the action has had its press state changed.

    open Unit

    Resets the view holder's view to unpressed state.

    open Unit

    Performs binding activator view value to action.

    open Unit

    Sets states of check mark view, called by onBindViewHolder(ViewHolder, GuidedAction) when action's checkset Id is other than GuidedAction#NO_CHECK_SET.

    open Unit

    Sets states of chevron view, called by onBindViewHolder(ViewHolder, GuidedAction).

    open Unit

    Binds a ViewHolder to a particular GuidedAction.

    open View!
    onCreateView(inflater: LayoutInflater!, container: ViewGroup!)

    Creates a view appropriate for displaying a list of GuidedActions, using the provided inflater and container.

    open GuidedActionsStylist.ViewHolder!

    Constructs a ViewHolder capable of representing GuidedActions.

    open GuidedActionsStylist.ViewHolder!
    onCreateViewHolder(parent: ViewGroup!, viewType: Int)

    Constructs a ViewHolder capable of representing GuidedActions.

    open Unit

    Called when destroy the View created by GuidedActionsStylist.

    open Unit
    onImeAppearing(@NonNull animators: MutableList<Animator!>)

    Animates the fragment in response to the IME appearing.

    open Unit
    onImeDisappearing(@NonNull animators: MutableList<Animator!>)

    Animates the fragment in response to the IME disappearing.

    open Int

    Provides the resource ID of the layout defining the view for an individual guided actions.

    open Int

    Provides the resource ID of the layout defining the view for an individual guided actions.

    open Int

    Provides the resource ID of the layout defining the host view for the list of guided actions.

    open Boolean

    Performs updating GuidedAction from activator view.

    open Unit

    Expand or collapse GuidedActionStylist.

    open Unit

    Switches action to edit mode and pops up the keyboard.

    open Unit

    Choose the layout resource for button actions in onProvideLayoutId().

    Unit

    Enable or disable using BACK key to collapse GuidedAction with editable activator view.

    Unit

    Enable or disable using BACK key to collapse sub actions list.

    open Unit

    open Unit

    Expands or collapse the sub actions list view with transition animation

    open Unit

    Start transition to expand or collapse GuidedActionStylist.

    Protected methods
    open Unit

    open Unit

    Called when editing mode of an ViewHolder is changed.

    open Unit

    Called by onBindViewHolder(ViewHolder, GuidedAction) to setup IME options.

    Constants

    VIEW_TYPE_DATE_PICKER

    static val VIEW_TYPE_DATE_PICKER: Int

    ViewType for DatePicker.

    Value: 1

    VIEW_TYPE_DEFAULT

    static val VIEW_TYPE_DEFAULT: Int

    Default viewType that associated with default layout Id for the action item.

    Value: 0

    Public constructors

    <init>

    GuidedActionsStylist()

    GuidedActionsStylist is used within a androidx.leanback.app.GuidedStepFragment to supply the right-side panel where users can take actions. It consists of a container for the list of actions, and a stationary selector view that indicates visually the location of focus. GuidedActionsStylist has two different layouts: default is for normal actions including text, radio, checkbox, DatePicker, etc, the other when setAsButtonActions() is called is recommended for button actions such as "yes", "no".

    Many aspects of the base GuidedActionsStylist can be customized through theming; see the theme attributes below. Note that these attributes are not set on individual elements in layout XML, but instead would be set in a custom theme. See Styles and Themes for more information.

    If these hooks are insufficient, this class may also be subclassed. Subclasses may wish to override the onProvideLayoutId method to change the layout used to display the list container and selector; override onProvideItemLayoutId(int) and getItemViewType(GuidedAction) method to change the layout used to display each action.

    To support a "click to activate" view similar to DatePicker, app needs:

  • Override onProvideItemLayoutId(int) and getItemViewType(GuidedAction), provides a layout id for the action.
  • The layout must include a widget with id "guidedactions_activator_item", the widget is toggled edit mode by View#setActivated(boolean).
  • Override onBindActivatorView(ViewHolder, GuidedAction) to populate values into View.
  • Override onUpdateActivatorView(ViewHolder, GuidedAction) to update action.

    Note: If an alternate list layout is provided, the following view IDs must be supplied:

    These view IDs must be present in order for the stylist to function. The list ID must correspond to a VerticalGridView or subclass.

    If an alternate item layout is provided, the following view IDs should be used to refer to base elements:

    These view IDs are allowed to be missing, in which case the corresponding views in will be null.

    In order to support editable actions, the view associated with guidedactions_item_title should be a subclass of android.widget.EditText, and should satisfy the interface and GuidedActionAutofillSupport interface. androidx.leanback.R.attr#guidedStepImeAppearingAnimation androidx.leanback.R.attr#guidedStepImeDisappearingAnimation androidx.leanback.R.attr#guidedActionsSelectorDrawable androidx.leanback.R.attr#guidedActionsListStyle androidx.leanback.R.attr#guidedSubActionsListStyle androidx.leanback.R.attr#guidedButtonActionsListStyle androidx.leanback.R.attr#guidedActionItemContainerStyle androidx.leanback.R.attr#guidedActionItemCheckmarkStyle androidx.leanback.R.attr#guidedActionItemIconStyle androidx.leanback.R.attr#guidedActionItemContentStyle androidx.leanback.R.attr#guidedActionItemTitleStyle androidx.leanback.R.attr#guidedActionItemDescriptionStyle androidx.leanback.R.attr#guidedActionItemChevronStyle androidx.leanback.R.attr#guidedActionPressedAnimation androidx.leanback.R.attr#guidedActionUnpressedAnimation androidx.leanback.R.attr#guidedActionEnabledChevronAlpha androidx.leanback.R.attr#guidedActionDisabledChevronAlpha androidx.leanback.R.attr#guidedActionTitleMinLines androidx.leanback.R.attr#guidedActionTitleMaxLines androidx.leanback.R.attr#guidedActionDescriptionMinLines androidx.leanback.R.attr#guidedActionVerticalPadding

  • Public methods

    collapseAction

    open fun collapseAction(withTransition: Boolean): Unit

    Collapse expanded action. Do nothing if it is in animation or there is no action expanded.

    Parameters
    withTransition Boolean: True to run transition animation, false otherwsie.

    expandAction

    open fun expandAction(
        action: GuidedAction!,
        withTransition: Boolean
    ): Unit

    Expand an action. Do nothing if it is in animation or there is action expanded.

    Parameters
    action GuidedAction!: Action to expand.
    withTransition Boolean: True to run transition animation, false otherwsie.

    getActionsGridView

    open fun getActionsGridView(): VerticalGridView!

    Returns the VerticalGridView that displays the list of GuidedActions.

    Return
    VerticalGridView! The VerticalGridView for this presenter.

    getExpandedAction

    open fun getExpandedAction(): GuidedAction!
    Return
    GuidedAction! Current expanded GuidedAction or null if not expanded.

    getItemViewType

    open fun getItemViewType(action: GuidedAction!): Int

    Return view type of action, each different type can have differently associated layout Id. Default implementation returns VIEW_TYPE_DEFAULT.

    Parameters
    action GuidedAction!: The action object.
    Return
    Int View type that used in onProvideItemLayoutId(int).

    getSubActionsGridView

    open fun getSubActionsGridView(): VerticalGridView!

    Returns the VerticalGridView that displays the sub actions list of an expanded action.

    Return
    VerticalGridView! The VerticalGridView that displays the sub actions list of an expanded action.

    isBackKeyToCollapseActivatorView

    fun isBackKeyToCollapseActivatorView(): Boolean
    Return
    Boolean True if using BACK key to collapse GuidedAction with editable activator view, false otherwise. Default value is true.

    isBackKeyToCollapseSubActions

    fun isBackKeyToCollapseSubActions(): Boolean
    Return
    Boolean True if using BACK key to collapse sub actions list, false otherwise. Default value is true.