ActionChooserView

public class ActionChooserView
extends View

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


The action chooser view allows the user to select from two options that are presented in the sides of the view. The view background is transparent so that it may be populated by the containing parent.

You can add this view to your layout as follows:

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

To set the properties of either option, you can call setOption(int, Drawable, int), specifying OPTION_START for the option at the start and OPTION_END for the option at the end:

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

Summary

Nested classes

interface ActionChooserView.ActionChooserListener

Interface for receiving callbacks about options chosen from an ActionChooserView

Constants

int OPTION_END

The option that appears at the end of the chooser.

int OPTION_START

The option that appears at the start of the chooser.

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)

Adds a listener to be notified when an option is chosen.

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

Selects the provided option, animating the option's icon to the center of the view and triggering the appropriate callbacks.

void removeListener(ActionChooserView.ActionChooserListener listener)

Removes a listener from receiving any future callbacks when an option is chosen.

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

Sets the characteristics of one of the predefined options, such as the option circle's color and the Drawable to be drawn in the middle.

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

The option that appears at the end of the chooser.

Constant Value: 2 (0x00000002)

OPTION_START

int OPTION_START

The option that appears at the start of the chooser.

Constant Value: 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)

Adds a listener to be notified when an option is chosen. see 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)

Selects the provided option, animating the option's icon to the center of the view and triggering the appropriate callbacks.

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

removeListener

void removeListener (ActionChooserView.ActionChooserListener listener)

Removes a listener from receiving any future callbacks when an option is chosen.

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)

Sets the characteristics of one of the predefined options, such as the option circle's color and the Drawable to be drawn in the middle.

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