belongs to Maven artifact com.android.support:leanback-v17:28.0.0-alpha1
Deprecated since version 27.1.0
GuidedStepFragment
public
class
GuidedStepFragment
extends Fragment
java.lang.Object | ||
↳ | android.app.Fragment | |
↳ | android.support.v17.leanback.app.GuidedStepFragment |
This class was deprecated
in API level 27.1.0.
use GuidedStepSupportFragment
A GuidedStepFragment is used to guide the user through a decision or series of decisions. It is composed of a guidance view on the left and a view on the right containing a list of possible actions.
Basic Usage
Clients of GuidedStepFragment must create a custom subclass to attach to their Activities. This custom subclass provides the information necessary to construct the user interface and respond to user actions. At a minimum, subclasses should override:
onCreateGuidance(Bundle)
, to provide instructions to the useronCreateActions(List
, to provide a set of, Bundle) GuidedAction
s the user can takeonGuidedActionClicked(GuidedAction)
, to respond to those actions
Clients use following helper functions to add GuidedStepFragment to Activity or FragmentManager:
addAsRoot(Activity, GuidedStepFragment, int)
, to be called during Activity onCreate, adds GuidedStepFragment as the first Fragment in activity.add(FragmentManager, GuidedStepFragment)
oradd(FragmentManager, GuidedStepFragment, int)
, to add GuidedStepFragment on top of existing Fragments or replacing existing GuidedStepFragment when moving forward to next step.finishGuidedStepFragments()
can either finish the activity or pop all GuidedStepFragment from stack.- If app chooses not to use the helper function, it is the app's responsibility to call
setUiStyle(int)
to select fragment transition and remember the stack entry where it need pops to.
Theming and Stylists
GuidedStepFragment delegates its visual styling to classes called stylists. The GuidanceStylist
is responsible for the left guidance view, while the GuidedActionsStylist
is responsible for the right actions view. The stylists use theme
attributes to derive values associated with the presentation, such as colors, animations, etc.
Most simple visual aspects of GuidanceStylist and GuidedActionsStylist can be customized
via theming; see their documentation for more information.
GuidedStepFragments must have access to an appropriate theme in order for the stylists to
function properly. Specifically, the fragment must receive Theme_Leanback_GuidedStep
, or a theme whose parent is
is set to that theme. Themes can be provided in one of three ways:
- The simplest way is to set the theme for the host Activity to the GuidedStep theme or a theme that derives from it.
- If the Activity already has a theme and setting its parent theme is inconvenient, the
existing Activity theme can have an entry added for the attribute
LeanbackGuidedStepTheme_guidedStepTheme
. If present, this theme will be used by GuidedStepFragment as an overlay to the Activity's theme. - Finally, custom subclasses of GuidedStepFragment may provide a theme through the
onProvideTheme()
method. This can be useful if a subclass is used across multiple Activities.
If the theme is provided in multiple ways, the onProvideTheme override has priority, followed by the Activity's theme. (Themes whose parent theme is already set to the guided step theme do not need to set the guidedStepTheme attribute; if set, it will be ignored.)
If themes do not provide enough customizability, the stylists themselves may be subclassed and
provided to the GuidedStepFragment through the onCreateGuidanceStylist()
and onCreateActionsStylist()
methods. The stylists have simple hooks so that subclasses
may override layout files; subclasses may also have more complex logic to determine styling.
Guided sequences
GuidedStepFragments can be grouped together to provide a guided sequence. GuidedStepFragments
grouped as a sequence use custom animations provided by GuidanceStylist
and
GuidedActionsStylist
(or subclasses) during transitions between steps. Clients
should use add(FragmentManager, GuidedStepFragment)
to place subsequent GuidedFragments onto the fragment stack so that
custom animations are properly configured. (Custom animations are triggered automatically when
the fragment stack is subsequently popped by any normal mechanism.)
Note: Currently GuidedStepFragments grouped in this way must all be defined programmatically, rather than in XML. This restriction may be removed in the future.
Summary
XML attributes | |
---|---|
LeanbackGuidedStepTheme_guidedActionContentWidthWeight |
|
LeanbackGuidedStepTheme_guidedActionContentWidthWeightTwoPanels |
|
LeanbackGuidedStepTheme_guidedActionsBackground |
|
LeanbackGuidedStepTheme_guidedActionsBackgroundDark |
|
LeanbackGuidedStepTheme_guidedActionsElevation |
|
LeanbackGuidedStepTheme_guidedStepBackground |
|
LeanbackGuidedStepTheme_guidedStepTheme |
Constants | |
---|---|
String |
EXTRA_UI_STYLE
Fragment argument name for UI style. |
int |
UI_STYLE_ACTIVITY_ROOT
One possible value of argument |
int |
UI_STYLE_DEFAULT
This constant was deprecated
in API level 24.1.0.
Same value as |
int |
UI_STYLE_ENTRANCE
Default value for argument |
int |
UI_STYLE_REPLACE
This is the case that we use GuidedStepFragment to replace another existing GuidedStepFragment when moving forward to next step. |
Inherited constants |
---|
![]()
android.content.ComponentCallbacks2
|
Public constructors | |
---|---|
GuidedStepFragment()
|
Public methods | |
---|---|
static
int
|
add(FragmentManager fragmentManager, GuidedStepFragment fragment, int id)
Adds the specified GuidedStepFragment to the fragment stack, replacing any existing GuidedStepFragments in the stack, and configuring the fragment-to-fragment custom transitions. |
static
int
|
add(FragmentManager fragmentManager, GuidedStepFragment fragment)
Adds the specified GuidedStepFragment to the fragment stack, replacing any existing GuidedStepFragments in the stack, and configuring the fragment-to-fragment custom transitions. |
static
int
|
addAsRoot(Activity activity, GuidedStepFragment fragment, int id)
Adds the specified GuidedStepFragment as content of Activity; no backstack entry is added so the activity will be dismissed when BACK key is pressed. |
void
|
collapseAction(boolean withTransition)
Collapse action which either has a sub actions list or action with
|
void
|
collapseSubActions()
Collapse sub actions list. |
void
|
expandAction(GuidedAction action, boolean withTransition)
Expand a given action with sub actions list or
|
void
|
expandSubActions(GuidedAction action)
Expand a given action's sub actions list. |
GuidedAction
|
findActionById(long id)
Find GuidedAction by Id. |
int
|
findActionPositionById(long id)
Find GuidedAction position in array by Id. |
GuidedAction
|
findButtonActionById(long id)
Find button GuidedAction by Id. |
int
|
findButtonActionPositionById(long id)
Find button GuidedAction position in array by Id. |
void
|
finishGuidedStepFragments()
Convenient method to close GuidedStepFragments on top of other content or finish Activity if GuidedStepFragments were started in a separate activity. |
View
|
getActionItemView(int position)
Returns the view corresponding to the action at the indicated position in the list of actions for this fragment. |
List<GuidedAction>
|
getActions()
Returns the list of GuidedActions that the user may take in this fragment. |
View
|
getButtonActionItemView(int position)
Returns the view corresponding to the button action at the indicated position in the list of actions for this fragment. |
List<GuidedAction>
|
getButtonActions()
Returns the list of button GuidedActions that the user may take in this fragment. |
static
GuidedStepFragment
|
getCurrentGuidedStepFragment(FragmentManager fm)
Returns the current GuidedStepFragment on the fragment transaction stack. |
GuidanceStylist
|
getGuidanceStylist()
Returns the GuidanceStylist that displays guidance information for the user. |
GuidedActionsStylist
|
getGuidedActionsStylist()
Returns the GuidedActionsStylist that displays the actions the user may take. |
GuidedActionsStylist
|
getGuidedButtonActionsStylist()
Returns the GuidedActionsStylist that displays the button actions the user may take. |
int
|
getSelectedActionPosition()
Returns the position if the currently selected GuidedAction. |
int
|
getSelectedButtonActionPosition()
Returns the position if the currently selected button GuidedAction. |
int
|
getUiStyle()
Read UI style from fragment arguments. |
boolean
|
isExpanded()
|
boolean
|
isFocusOutEndAllowed()
Returns true if allows focus out of end edge of GuidedStepFragment, false otherwise. |
boolean
|
isFocusOutStartAllowed()
Returns true if allows focus out of start edge of GuidedStepFragment, false otherwise. |
boolean
|
isSubActionsExpanded()
|
void
|
notifyActionChanged(int position)
Notify an action has changed and update its UI. |
void
|
notifyButtonActionChanged(int position)
Notify an button action has changed and update its UI. |
void
|
onCreate(Bundle savedInstanceState)
|
void
|
onCreateActions(List<GuidedAction> actions, Bundle savedInstanceState)
Fills out the set of actions available to the user. |
GuidedActionsStylist
|
onCreateActionsStylist()
Creates the presenter used to style the guided actions panel. |
View
|
onCreateBackgroundView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
Called by onCreateView to inflate background view. |
void
|
onCreateButtonActions(List<GuidedAction> actions, Bundle savedInstanceState)
Fills out the set of actions shown at right available to the user. |
GuidedActionsStylist
|
onCreateButtonActionsStylist()
Creates the presenter used to style a sided actions panel for button only. |
|