ActionChooserView

public class ActionChooserView
extends View

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


This class is deprecated.
this approach is no longer preferred. Consider using regular Android classes instead, such as dialogs (eg. AlertDialog)

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

This interface is deprecated. this interface is deprecated along with the rest of this class.  

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

Inherited fields

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

Constants

OPTION_END

public static final int OPTION_END

The option that appears at the end of the chooser.

Constant Value: 2 (0x00000002)

OPTION_START

public static final int OPTION_START

The option that appears at the start of the chooser.

Constant Value: 1 (0x00000001)

Public constructors

ActionChooserView

public ActionChooserView (Context context)

Parameters
context Context

ActionChooserView

public ActionChooserView (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

ActionChooserView

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

Parameters
context Context

attrs AttributeSet

defStyleAttr int

Public methods

addListener

public void addListener (ActionChooserView.ActionChooserListener listener)

Adds a listener to be notified when an option is chosen. see ActionChooserView.ActionChooserListener.onOptionChosen(int)

Parameters
listener ActionChooserView.ActionChooserListener: The listener to add.

canScrollHorizontally

public boolean canScrollHorizontally (int direction)

Parameters
direction int

Returns
boolean

onTouchEvent

public boolean onTouchEvent (MotionEvent event)

Parameters
event MotionEvent

Returns
boolean

performSelectOption

public 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

public 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

public void setEnabled (boolean enabled)

Parameters
enabled boolean

setOption

public 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

protected void onAttachedToWindow ()

onDetachedFromWindow

protected void onDetachedFromWindow ()

onDraw

protected void onDraw (Canvas canvas)

Parameters
canvas Canvas

onLayout

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

Parameters
changed boolean

left int

top int

right int

bottom int