ActionChooserView

public class ActionChooserView
extends View

java.lang.Object
   ↳ android.view.View
     ↳ android.support.wearable.view.ActionChooserView


动作选择器视图允许用户从视图两侧出现的两个选项中进行选择。 视图背景是透明的,以便它可以由包含的父项填充。

您可以按如下方式将此视图添加到布局中:

     <android.support.wearable.view.ActionChooserView
          android:id="@+id/actions"
          android:layout_width="match_parent"
          android:layout_height="match_parent" />
 

要设置任一选项,你可以调用的属性 setOption(int, Drawable, int) ,指定 OPTION_START在开始和选项 OPTION_END在年底的选项:

mChooserView.setOption(ActionChooserView.OPTION_START,acceptIcon,getResources()。getColor(R.color.option_color));

Summary

Nested classes

interface ActionChooserView.ActionChooserListener

用于接收有关从ActionChooserView选择的选项的回调接口。

Constants

int OPTION_END

出现在选择器末尾的选项。

int OPTION_START

出现在选择器开始处的选项。

Inherited constants

From class android.view.View

Inherited fields

From class android.view.View

Public constructors

ActionChooserView(Context context)
ActionChooserView(Context context, AttributeSet attrs)
ActionChooserView(Context context, AttributeSet attrs, int defStyleAttr)

Public methods

void addListener(ActionChooserView.ActionChooserListener listener)

添加一个侦听器,当选择一个选项时将被通知。

boolean canScrollHorizontally(int direction)
boolean onTouchEvent(MotionEvent event)
void performSelectOption(int option)

选择提供的选项,将选项图标动画化到视图的中心并触发适当的回调。

void removeListener(ActionChooserView.ActionChooserListener listener)

当选择一个选项时,删除监听器接收未来的回调。

void setEnabled(boolean enabled)
void setOption(int option, Drawable drawable, int color)

设置其中一个预定义选项的特征,例如选项圆的颜色和要在中间绘制的 Drawable

Protected methods

void onAttachedToWindow()
void onDetachedFromWindow()
void onDraw(Canvas canvas)
void onLayout(boolean changed, int left, int top, int right, int bottom)

Inherited methods

From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

Constants

OPTION_END

int OPTION_END

出现在选择器末尾的选项。

常量值:2(0x00000002)

OPTION_START

int OPTION_START

出现在选择器开始处的选项。

常数值:1(0x00000001)

Public constructors

ActionChooserView

ActionChooserView (Context context)

Parameters
context Context

ActionChooserView

ActionChooserView (Context context,
                AttributeSet attrs)

Parameters
context Context
attrs AttributeSet

ActionChooserView

ActionChooserView (Context context,
                AttributeSet attrs,
                int defStyleAttr)

Parameters
context Context
attrs AttributeSet
defStyleAttr int

Public methods

addListener

void addListener (ActionChooserView.ActionChooserListener listener)

添加一个侦听器,当选择一个选项时将被通知。 onOptionChosen(int)

Parameters
listener ActionChooserView.ActionChooserListener: The listener to add.

canScrollHorizontally

boolean canScrollHorizontally (int direction)

Parameters
direction int
Returns
boolean

onTouchEvent

boolean onTouchEvent (MotionEvent event)

Parameters
event MotionEvent
Returns
boolean

performSelectOption

void performSelectOption (int option)

选择提供的选项,将选项图标动画化到视图的中心并触发适当的回调。

Parameters
option int: The option to select, either OPTION_START or OPTION_END.

removeListener

void removeListener (ActionChooserView.ActionChooserListener listener)

当选择一个选项时,删除监听器接收未来的回调。

Parameters
listener ActionChooserView.ActionChooserListener: The listener to remove.

setEnabled

void setEnabled (boolean enabled)

Parameters
enabled boolean

setOption

void setOption (int option,
                Drawable drawable,
                int color)

设置其中一个预定义选项的特征,例如选项圆的颜色和要在中间绘制的 Drawable

Parameters
option int: The option to set, either OPTION_START or OPTION_END.
drawable Drawable: The drawable to draw in the center of the option circle.
color int: The color of the option circle.

Protected methods

onAttachedToWindow

void onAttachedToWindow ()

onDetachedFromWindow

void onDetachedFromWindow ()

onDraw

void onDraw (Canvas canvas)

Parameters
canvas Canvas

onLayout

void onLayout (boolean changed,
                int left,
                int top,
                int right,
                int bottom)

Parameters
changed boolean
left int
top int
right int
bottom int