Join us on the livestream at Android Dev Summit on 7-8 November 2018, starting at 10AM PDT!

WearableActionDrawerView

public class WearableActionDrawerView
extends WearableDrawerView

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ androidx.wear.widget.drawer.WearableDrawerView
           ↳ androidx.wear.widget.drawer.WearableActionDrawerView


Ease of use class for creating a Wearable action drawer. This can be used with WearableDrawerLayout to create a drawer for users to easily pull up contextual actions. These contextual actions may be specified by using a Menu, which may be populated by either:

  • Specifying the app:actionMenu attribute in the XML layout file. Example:
     <androidx.wear.widget.drawer.WearableActionDrawerView
         xmlns:app="http://schemas.android.com/apk/res-auto"
         android:layout_width=”match_parent”
         android:layout_height=”match_parent”
         app:actionMenu="@menu/action_drawer" />
  • Getting the menu with getMenu(), and then inflating it with MenuInflater.inflate(int, Menu). Example:
     Menu menu = actionDrawer.getMenu();
     getMenuInflater().inflate(R.menu.action_drawer, menu);

The full Menu and MenuItem APIs are not implemented. The following methods are guaranteed to work:

For Menu, the add methods, Menu.clear(), Menu.removeItem(int), Menu.findItem(int), Menu.size(), and Menu.getItem(int) are implemented.

For MenuItem, setting and getting the title and icon, MenuItem.getItemId(), and MenuItem.setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener) are implemented.

Summary

Inherited constants

Inherited fields

Public constructors

WearableActionDrawerView(Context context)
WearableActionDrawerView(Context context, AttributeSet attrs)
WearableActionDrawerView(Context context, AttributeSet attrs, int defStyleAttr)
WearableActionDrawerView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Public methods

boolean canScrollHorizontally(int direction)
Menu getMenu()

Returns the Menu object that this WearableActionDrawer represents.

void onDrawerOpened()

Called when the drawer has settled in a completely open state.

void onPeekContainerClicked(View v)

Called when anything within the peek container is clicked.

void setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener listener)

Set a MenuItem.OnMenuItemClickListener for this action drawer.

void setTitle(CharSequence title)

Sets the title for this action drawer.

Inherited methods

Public constructors

WearableActionDrawerView

public WearableActionDrawerView (Context context)

Parameters
context Context

WearableActionDrawerView

public WearableActionDrawerView (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

WearableActionDrawerView

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

Parameters
context Context

attrs AttributeSet

defStyleAttr int

WearableActionDrawerView

public WearableActionDrawerView (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

defStyleRes int

Public methods

canScrollHorizontally

public boolean canScrollHorizontally (int direction)

Parameters
direction int

Returns
boolean

getMenu

public Menu getMenu ()

Returns the Menu object that this WearableActionDrawer represents.

Applications should use this method to obtain the WearableActionDrawers's Menu object and inflate or add content to it as necessary.

Returns
Menu the Menu presented by this view

onDrawerOpened

public void onDrawerOpened ()

Called when the drawer has settled in a completely open state. The drawer is interactive at this point. This is analogous to WearableDrawerLayout.DrawerStateCallback.onDrawerOpened(WearableDrawerLayout, WearableDrawerView).

onPeekContainerClicked

public void onPeekContainerClicked (View v)

Called when anything within the peek container is clicked. However, if a custom peek view is supplied and it handles the click, then this may not be called. The default behavior is to open the drawer.

Parameters
v View

setOnMenuItemClickListener

public void setOnMenuItemClickListener (MenuItem.OnMenuItemClickListener listener)

Set a MenuItem.OnMenuItemClickListener for this action drawer.

Parameters
listener MenuItem.OnMenuItemClickListener

setTitle

public void setTitle (CharSequence title)

Sets the title for this action drawer. If title is null, then the title will be removed.

Parameters
title CharSequence