public class GuidedActionsStylist
extends Object implements FragmentAnimationProvider
| java.lang.Object | |
| android.support.v17.leanback.widget.GuidedActionsStylist | |
GuidedActionsStylist在GuidedStepFragment用于提供用户可以采取行动的右侧面板。 它由用于动作列表的容器和静止的选择器视图组成,该视图以可视方式指示焦点的位置。 GuidedActionsStylist有两种不同的布局:默认为正常操作,包括文本,广播,复选框,DatePicker等,另一个当setAsButtonActions()时,推荐用于诸如“yes”,“no”等按钮操作。
基础GuidedActionsStylist的许多方面都可以通过主题进行定制; 请参阅下面的主题属性。 请注意,这些属性不是在布局XML中的单个元素上设置的,而是在自定义主题中设置的。 有关更多信息,请参阅Styles and Themes 。
如果这些钩子不够用,这个类别也可能被分类。 子类可能希望覆盖onProvideLayoutId()方法来更改用于显示列表容器和选择器的布局; 覆盖onProvideItemLayoutId(int)和getItemViewType(GuidedAction)方法来更改用于显示每个操作的布局。
要支持类似于DatePicker的“点击激活”视图,应用程序需要:
onProvideItemLayoutId(int) and getItemViewType(GuidedAction), provides a layout id for the action. setActivated(boolean). onBindActivatorView(ViewHolder, GuidedAction) to populate values into View. onUpdateActivatorView(ViewHolder, GuidedAction) to update action. 注意:如果提供备用列表布局,则必须提供以下视图ID:
这些视图ID必须存在才能让设计师发挥作用。 列表ID必须对应于VerticalGridView或子类。
如果提供了替代项目布局,则应使用以下视图ID来引用基本元素:
guidedactions_item_contentguidedactions_item_titleguidedactions_item_descriptionguidedactions_item_iconguidedactions_item_checkmarkguidedactions_item_chevron这些视图ID可以丢失,在这种情况下, GuidedActionsStylist.ViewHolder的相应视图将为空。
为了支持可编辑的动作,与guidedactions_item_title相关联的视图应该是的一个子类 EditText ,并应满足 ImeKeyMonitor接口。
也可以看看:
Nested classes |
|
|---|---|
class |
GuidedActionsStylist.ViewHolder ViewHolder缓存关于操作项目布局子视图的信息。 |
XML attributes |
|
|---|---|
android.support.v17.leanback:guidedActionDescriptionMinLines |
Theme attribute used in a GuidedActionsPresenter for the max lines of the title text view when the action's isMultilineDescription is set to false. |
android.support.v17.leanback:guidedActionDisabledChevronAlpha |
Theme attribute used in a GuidedActionsPresenter for the alpha value of the chevron decoration when its action is disabled. |
android.support.v17.leanback:guidedActionEnabledChevronAlpha |
Theme attribute used in a GuidedActionsPresenter for the alpha value of the chevron decoration when its action is enabled. |
android.support.v17.leanback:guidedActionItemCheckmarkStyle |
Theme attribute for the style of an action's checkmark in a GuidedActionsPresenter. |
android.support.v17.leanback:guidedActionItemChevronStyle |
Theme attribute for the style of an action's chevron decoration in a GuidedActionsPresenter. |
android.support.v17.leanback:guidedActionItemContainerStyle |
Theme attribute for the style of the container of a single action in a GuidedActionsPresenter. |
android.support.v17.leanback:guidedActionItemContentStyle |
Theme attribute for the style of an action's content in a GuidedActionsPresenter. |
android.support.v17.leanback:guidedActionItemDescriptionStyle |
Theme attribute for the style of an action's description in a GuidedActionsPresenter. |
android.support.v17.leanback:guidedActionItemIconStyle |
Theme attribute for the style of an action's icon in a GuidedActionsPresenter. |
android.support.v17.leanback:guidedActionItemTitleStyle |
Theme attribute for the style of an action's title in a GuidedActionsPresenter. |
android.support.v17.leanback:guidedActionPressedAnimation |
Theme attribute for the animation used in a GuidedActionsPresenter when an action is pressed. |
android.support.v17.leanback:guidedActionTitleMaxLines |
Theme attribute used in a GuidedActionsPresenter for the max lines of the title text view when the action's isMultilineDescription is set to true. |
android.support.v17.leanback:guidedActionTitleMinLines |
Theme attribute used in a GuidedActionsPresenter for the max lines of the title text view when the action's isMultilineDescription is set to false. |
android.support.v17.leanback:guidedActionUnpressedAnimation |
Theme attribute for the animation used in a GuidedActionsPresenter when an action is unpressed. |
android.support.v17.leanback:guidedActionVerticalPadding |
Theme attribute used in a GuidedActionsPresenter for the vertical padding between action views in the list. |
android.support.v17.leanback:guidedActionsListStyle |
Theme attribute for the style of the list in a GuidedActionsPresenter. |
android.support.v17.leanback:guidedActionsSelectorDrawable |
Theme attribute for the style of the item selector in a GuidedActionsPresenter. |
android.support.v17.leanback:guidedButtonActionsListStyle |
Theme attribute for the style of the list in a GuidedActionsPresenter. |
android.support.v17.leanback:guidedStepImeAppearingAnimation |
Theme attribute for the animation used when a guided step element is animated in response to the IME appearing. |
android.support.v17.leanback:guidedStepImeDisappearingAnimation |
Theme attribute for the animation used when a guided step element is animated in response to the IME disappearing. |
android.support.v17.leanback:guidedSubActionsListStyle |
Theme attribute for the style of the sub actions list in a GuidedActionsPresenter. |
常量(Constants) |
|
|---|---|
int |
VIEW_TYPE_DATE_PICKER DatePicker的ViewType。 |
int |
VIEW_TYPE_DEFAULT 与操作项目的默认布局ID关联的默认视图类型。 |
Public constructors |
|
|---|---|
GuidedActionsStylist() |
|
Protected methods |
|
|---|---|
void |
onEditingModeChange(GuidedActionsStylist.ViewHolder vh, GuidedAction action, boolean editing) |
void |
setupImeOptions(GuidedActionsStylist.ViewHolder vh, GuidedAction action) 由 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
android.support.v17.leanback.widget.FragmentAnimationProvider
|
|
当动作的isMultilineDescription设置为false时,GuidedActionsPresenter中使用的主题属性用于标题文本视图的最大行数。 默认是lb_guidedactions_item_description_min_lines 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
GuidedActionsPresenter中使用的主题属性,用于禁用其动作时的V形装饰的Alpha值。 默认是lb_guidedactions_item_disabled_chevron_alpha 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
GuidedActionsPresenter中使用的主题属性,用于启用动作时的V形装饰的Alpha值。 默认是lb_guidedactions_item_enabled_chevron_alpha 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
GuidedActionsPresenter中动作复选标记样式的主题属性。 默认是Widget_Leanback_GuidedActionItemCheckmarkStyle 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
GuidedActionsPresenter中动作的V形装饰风格的主题属性。 默认是Widget_Leanback_GuidedActionItemChevronStyle 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
GuidedActionsPresenter中单个动作的容器样式的主题属性。 默认是Widget_Leanback_GuidedActionItemContainerStyle 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
GuidedActionsPresenter中动作内容样式的主题属性。 默认是Widget_Leanback_GuidedActionItemContentStyle 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
GuidedActionsPresenter中动作描述样式的主题属性。 默认是Widget_Leanback_GuidedActionItemDescriptionStyle 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
GuidedActionsPresenter中动作图标样式的主题属性。 默认是Widget_Leanback_GuidedActionItemIconStyle 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
GuidedActionsPresenter中动作标题样式的主题属性。 默认是Widget_Leanback_GuidedActionItemTitleStyle 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
按下操作时GuidedActionsPresenter中使用的动画的主题属性。 默认是lb_guidedactions_item_pressed 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
当动作的isMultilineDescription设置为true时,GuidedActionsPresenter中使用的主题属性用于标题文本视图的最大行数。 默认是lb_guidedactions_item_title_max_lines 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
当动作的isMultilineDescription设置为false时,GuidedActionsPresenter中使用的主题属性用于标题文本视图的最大行数。 默认是lb_guidedactions_item_title_min_lines 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
GuidedActionsPresenter在动作未按下时使用的动画的主题属性。 默认是lb_guidedactions_item_unpressed 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
用于GuidedActionsPresenter中的主题属性,用于列表中动作视图之间的垂直填充。 默认是lb_guidedactions_vertical_padding 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
GuidedActionsPresenter中列表样式的主题属性。 默认是Widget_Leanback_GuidedActionsListStyle 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
GuidedActionsPresenter中项目选择器样式的主题属性。 默认是?android:attr / selectableItemBackground。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
GuidedActionsPresenter中列表样式的主题属性。 默认是Widget_Leanback_GuidedButtonActionsListStyle 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
当引导的步骤元素响应IME出现而动画时使用的动画的主题属性。 默认是lb_guidedstep_slide_up 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
当导入的步骤元素响应IME消失而动画时使用的动画的主题属性。 默认是lb_guidedstep_slide_down 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
GuidedActionsPresenter中子动作列表的样式的主题属性。 默认是Widget_Leanback_GuidedSubActionsListStyle 。
可能是另一种资源的引用,其形式为“ @[+][package:]type/name ”或形式为“一个主题属性 ?[package:]type/name ”。
int VIEW_TYPE_DATE_PICKER
DatePicker的ViewType。
常数值:1(0x00000001)
int VIEW_TYPE_DEFAULT
与操作项目的默认布局ID关联的默认视图类型。
常量值:0(0x00000000)
GuidedActionsStylist ()
VerticalGridView getActionsGridView ()
返回显示GuidedActions列表的VerticalGridView。
| 返回(Returns) | |
|---|---|
VerticalGridView |
The VerticalGridView for this presenter. |
GuidedAction getExpandedAction ()
| 返回(Returns) | |
|---|---|
GuidedAction |
Current expanded GuidedAction or null if not expanded. |
int getItemViewType (GuidedAction action)
返回视图类型的操作,每种不同的类型可以有不同的关联布局ID。 默认实现返回VIEW_TYPE_DEFAULT 。
| 参数(Parameters) | |
|---|---|
action |
GuidedAction: The action object. |
| 返回(Returns) | |
|---|---|
int |
View type that used in onProvideItemLayoutId(int). |
VerticalGridView getSubActionsGridView ()
返回显示展开操作的子操作列表的VerticalGridView。
| 返回(Returns) | |
|---|---|
VerticalGridView |
The VerticalGridView that displays the sub actions list of an expanded action. |
boolean isButtonActions ()
如果它是按钮操作列表,则返回true;对于普通操作列表,则返回false。
| 返回(Returns) | |
|---|---|
boolean |
True if it is button actions list, false for normal actions list. |
boolean isExpandTransitionSupported ()
返回是否支持展开/折叠动画。 当此方法返回true时,将使用startExpandedTransition(ViewHolder) 。 当此方法返回false时,将调用onUpdateExpandedViewHolder(ViewHolder) 。
| 返回(Returns) | |
|---|---|
boolean |
True if it is running an expanding or collapsing transition, false otherwise. |
boolean isInExpandTransition ()
如果正在运行展开或折叠转换,则返回true,否则返回false。
| 返回(Returns) | |
|---|---|
boolean |
True if it is running an expanding or collapsing transition, false otherwise. |
boolean isSubActionsExpanded ()
| 返回(Returns) | |
|---|---|
boolean |
True if sub actions list is expanded. |
void onAnimateItemChecked (GuidedActionsStylist.ViewHolder vh, boolean checked)
当动作的检查状态改变时,动画化视图持有者的视图(或其子视图)。 默认实现调用setChecked()如果getCheckmarkView()是实例Checkable 。
| 参数(Parameters) | |
|---|---|
vh |
GuidedActionsStylist.ViewHolder: The view holder associated with the relevant action. |
checked |
boolean: True if the action has become checked, false if it has become unchecked. |
void onAnimateItemFocused (GuidedActionsStylist.ViewHolder vh, boolean focused)
当动作的焦点状态改变时,动画化视图持有者的视图(或其子视图)。
| 参数(Parameters) | |
|---|---|
vh |
GuidedActionsStylist.ViewHolder: The view holder associated with the relevant action. |
focused |
boolean: True if the action has become focused, false if it has lost focus. |
void onAnimateItemPressed (GuidedActionsStylist.ViewHolder vh, boolean pressed)
当动作的按下状态改变时,动画化视图持有者的视图(或其子视图)。
| 参数(Parameters) | |
|---|---|
vh |
GuidedActionsStylist.ViewHolder: The view holder associated with the relevant action. |
pressed |
boolean: True if the action has been pressed, false if it has been unpressed. |
void onAnimateItemPressedCancelled (GuidedActionsStylist.ViewHolder vh)
将视图持有者的视图重置为未按下状态。
| 参数(Parameters) | |
|---|---|
vh |
GuidedActionsStylist.ViewHolder: The view holder associated with the relevant action. |
void onBindActivatorView (GuidedActionsStylist.ViewHolder vh, GuidedAction action)
将绑定激活器视图值执行到操作。 默认实现支持GuidedDatePickerAction,子类可以重载以添加对其他视图的支持。
| 参数(Parameters) | |
|---|---|
vh |
GuidedActionsStylist.ViewHolder: ViewHolder of activator view. |
action |
GuidedAction: GuidedAction to bind. |
void onBindCheckMarkView (GuidedActionsStylist.ViewHolder vh, GuidedAction action)
当操作的检查集ID不是NO_CHECK_SET时,设置复选标记视图的状态,由onBindViewHolder(ViewHolder, GuidedAction) NO_CHECK_SET 。 默认实现为复选框分配从主题属性listChoiceIndicatorMultiple加载的drawable,或者为单选按钮分配listChoiceIndicatorSingle 。 子类很少需要重写该方法,而是应用程序可以提供自己的可绘制对象,以支持过渡动画,更改{android.support.v17.leanback.R中的主题属性listChoiceIndicatorMultiple和listChoiceIndicatorSingle 。 设置样式#LeanbackGuidedStepTheme}。
| 参数(Parameters) | |
|---|---|
vh |
GuidedActionsStylist.ViewHolder: The view holder associated with the relevant action. |
action |
GuidedAction: The GuidedAction object to bind to. |
void onBindChevronView (GuidedActionsStylist.ViewHolder vh, GuidedAction action)
设置V形视图的状态,由onBindViewHolder(ViewHolder, GuidedAction) 。 子类可能会覆盖。
| 参数(Parameters) | |
|---|---|
vh |
GuidedActionsStylist.ViewHolder: The view holder associated with the relevant action. |
action |
GuidedAction: The GuidedAction object to bind to. |
void onBindViewHolder (GuidedActionsStylist.ViewHolder vh, GuidedAction action)
将 GuidedActionsStylist.ViewHolder绑定到特定的 GuidedAction 。
| 参数(Parameters) | |
|---|---|
vh |
GuidedActionsStylist.ViewHolder: The view holder to be associated with the given action. |
action |
GuidedAction: The guided action to be displayed by the view holder's view. |
| 返回(Returns) | |
|---|---|
void |
The view to be added to the caller's view hierarchy. |
View onCreateView (LayoutInflater inflater, ViewGroup container)
使用提供的inflater和容器创建适合显示GuidedAction列表的视图。
注意:实际上并没有将创建的视图添加到容器中; 来电者应该这样做。
| 参数(Parameters) | |
|---|---|
inflater |
LayoutInflater: The layout inflater to be used when constructing the view. |
container |
ViewGroup: The view group to be passed in the call to LayoutInflater.inflate. |
| 返回(Returns) | |
|---|---|
View |
The view to be added to the caller's view hierarchy. |
GuidedActionsStylist.ViewHolder onCreateViewHolder (ViewGroup parent, int viewType)
构造一个GuidedActionsStylist.ViewHolder能够表示GuidedAction秒。 子类可以选择返回ViewHolder的子类。
注意:实际上不应该将创建的视图添加到父级; 来电者会这样做。
| 参数(Parameters) | |
|---|---|
parent |
ViewGroup: The view group to be used as the parent of the new view. |
viewType |
int: The viewType returned by getItemViewType(GuidedAction) |
| 返回(Returns) | |
|---|---|
GuidedActionsStylist.ViewHolder |
The view to be added to the caller's view hierarchy. |
GuidedActionsStylist.ViewHolder onCreateViewHolder (ViewGroup parent)
构造一个GuidedActionsStylist.ViewHolder能够表示GuidedAction秒。 子类可以选择返回ViewHolder的子类。 要支持不同的视图类型,请覆盖onCreateViewHolder(ViewGroup, int)
注意:实际上不应该将创建的视图添加到父级; 来电者会这样做。
| 参数(Parameters) | |
|---|---|
parent |
ViewGroup: The view group to be used as the parent of the new view. |
| 返回(Returns) | |
|---|---|
GuidedActionsStylist.ViewHolder |
The view to be added to the caller's view hierarchy. |
void onDestroyView ()
在销毁由GuidedActionsStylist创建的视图时调用。
void onImeAppearing (List<Animator> animators)
动画片段响应IME出现。
| 参数(Parameters) | |
|---|---|
animators |
List: A list of animations to which this provider's animations should be added. |
void onImeDisappearing (List<Animator> animators)
动画片段以响应IME消失。
| 参数(Parameters) | |
|---|---|
animators |
List: A list of animations to which this provider's animations should be added. |
int onProvideItemLayoutId ()
为单个指导操作提供定义视图的布局的资源ID。 子类可以覆盖以提供他们自己的自定义布局。 基本实现返回lb_guidedactions_item 。 如果被覆盖,替换的布局应该包含任何应该由基类管理的视图的匹配ID; 这可以通过从基本布局文件的副本开始来实现。 请注意,为了使项目支持编辑,标题视图应该EditText和ImeKeyMonitor ; 见GuidedActionEditText 。 要支持不同类型的布局,请覆盖onProvideItemLayoutId(int) 。
| 返回(Returns) | |
|---|---|
int |
The resource ID of the layout to be inflated to define the view to display an individual GuidedAction. |
int onProvideItemLayoutId (int viewType)
为单个指导操作提供定义视图的布局的资源ID。 子类可以覆盖以提供他们自己的自定义布局。 基本实现支持:
lb_guidedactions_item lb_guidedactions_datepicker_item. If overridden, the substituted layout should contain matching IDs for any views that should be managed by the base class; this can be achieved by starting with a copy of the base layout file. Note that in order for the item to support editing, the title view should both subclass EditText and implement ImeKeyMonitor; see GuidedActionEditText.
| 参数(Parameters) | |
|---|---|
viewType |
int: View type returned by getItemViewType(GuidedAction) |
| 返回(Returns) | |
|---|---|
int |
The resource ID of the layout to be inflated to define the view to display an individual GuidedAction. |
int onProvideLayoutId ()
提供定义指导操作列表的主机视图的布局的资源ID。 子类可以覆盖以提供他们自己的自定义布局。 如果isButtonActions()为true,则基本实现将返回lb_guidedactions或lb_guidedbuttonactions 。 如果被覆盖,替换的布局应该包含任何应该由基类管理的视图的匹配ID; 这可以通过从基本布局文件的副本开始来实现。
| 返回(Returns) | |
|---|---|
int |
The resource ID of the layout to be inflated to define the host view for the list of GuidedActions. |
boolean onUpdateActivatorView (GuidedActionsStylist.ViewHolder vh, GuidedAction action)
从激活器视图执行更新GuidedAction。 默认实现支持GuidedDatePickerAction,子类可以重载以添加对其他视图的支持。
| 参数(Parameters) | |
|---|---|
vh |
GuidedActionsStylist.ViewHolder: ViewHolder of activator view. |
action |
GuidedAction: GuidedAction to update. |
| 返回(Returns) | |
|---|---|
boolean |
True if value has been updated, false otherwise. |
void onUpdateExpandedViewHolder (GuidedActionsStylist.ViewHolder avh)
展开或折叠GuidedActionStylist。
| 参数(Parameters) | |
|---|---|
avh |
GuidedActionsStylist.ViewHolder: When not null, the GuidedActionStylist expands the sub actions of avh. When null the GuidedActionStylist will collapse sub actions. |
void setEditingMode (GuidedActionsStylist.ViewHolder vh, GuidedAction action, boolean editing)
| 参数(Parameters) | |
|---|---|
vh |
GuidedActionsStylist.ViewHolder
|
action |
GuidedAction
|
editing |
boolean
|
void setExpandedViewHolder (GuidedActionsStylist.ViewHolder avh)
展开或折叠子动作列表视图。
| 参数(Parameters) | |
|---|---|
avh |
GuidedActionsStylist.ViewHolder: When not null, fill sub actions list of this ViewHolder into sub actions list and hide the other items in main list. When null, collapse the sub actions list. |
void startExpandedTransition (GuidedActionsStylist.ViewHolder avh)
开始转换以展开或折叠GuidedActionStylist。
| 参数(Parameters) | |
|---|---|
avh |
GuidedActionsStylist.ViewHolder: When not null, the GuidedActionStylist expands the sub actions of avh. When null the GuidedActionStylist will collapse sub actions. |
void onEditingModeChange (GuidedActionsStylist.ViewHolder vh, GuidedAction action, boolean editing)
| 参数(Parameters) | |
|---|---|
vh |
GuidedActionsStylist.ViewHolder
|
action |
GuidedAction
|
editing |
boolean
|
void setupImeOptions (GuidedActionsStylist.ViewHolder vh, GuidedAction action)
由onBindViewHolder(ViewHolder, GuidedAction)调用以设置IME选项。 默认实现分配IME_ACTION_DONE 。 子类可能会覆盖。
| 参数(Parameters) | |
|---|---|
vh |
GuidedActionsStylist.ViewHolder: The view holder to be associated with the given action. |
action |
GuidedAction: The guided action to be displayed by the view holder's view. |