Skip to content

Most visited

Recently visited

navigation
added in version 26.1.0
belongs to Maven artifact com.android.support:wear:27.0.0

WearableNavigationDrawerView

public class WearableNavigationDrawerView
extends WearableDrawerView

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ android.support.wear.widget.drawer.WearableDrawerView
           ↳ android.support.wear.widget.drawer.WearableNavigationDrawerView


Ease of use class for creating a Wearable navigation drawer. This can be used with WearableDrawerLayout to create a drawer for users to easily navigate a wearable app.

There are two ways this information may be presented: as a single page and as multiple pages. The single page navigation drawer will display 1-7 items to the user representing different navigation verticals. If more than 7 items are provided to a single page navigation drawer, the navigation drawer will be displayed as empty. The multiple page navigation drawer will display 1 or more pages to the user, each representing different navigation verticals.

The developer may specify which style to use with the app:navigationStyle custom attribute. If not specified, singlePage will be used as the default.

Summary

Nested classes

interface WearableNavigationDrawerView.OnItemSelectedListener

Listener which is notified when the user selects an item. 

class WearableNavigationDrawerView.WearableNavigationDrawerAdapter

Adapter for specifying the contents of WearableNavigationDrawer. 

Constants

int MULTI_PAGE

Multi-page navigation drawer style.

int SINGLE_PAGE

Single page navigation drawer style.

Inherited constants

From class android.support.wear.widget.drawer.WearableDrawerView
From class android.view.ViewGroup
From class android.view.View

Inherited fields

From class android.view.View

Public constructors

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

Public methods

void addOnItemSelectedListener(WearableNavigationDrawerView.OnItemSelectedListener listener)

Add an WearableNavigationDrawerView.OnItemSelectedListener that will be notified when the user selects an item.

boolean canScrollHorizontally(int direction)
int getNavigationStyle()

Returns the style this drawer is using, either SINGLE_PAGE or MULTI_PAGE.

void onDrawerClosed()

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

void onDrawerOpened()

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

boolean onInterceptTouchEvent(MotionEvent ev)
void removeOnItemSelectedListener(WearableNavigationDrawerView.OnItemSelectedListener listener)

Remove an WearableNavigationDrawerView.OnItemSelectedListener.

void setAdapter(WearableNavigationDrawerView.WearableNavigationDrawerAdapter adapter)

Set a WearableNavigationDrawerView.WearableNavigationDrawerAdapter that will supply data for this drawer.

void setCurrentItem(int index, boolean smoothScrollTo)

Changes which index is selected.

Inherited methods

From class android.support.wear.widget.drawer.WearableDrawerView
From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.view.ViewParent
From interface android.view.ViewManager
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

Constants

MULTI_PAGE

added in version 26.1.0
int MULTI_PAGE

Multi-page navigation drawer style. Each item is on its own page. Useful when more than 7 items exist.

Constant Value: 1 (0x00000001)

SINGLE_PAGE

added in version 26.1.0
int SINGLE_PAGE

Single page navigation drawer style. This is the default drawer style. It is ideal for 1-5 items, but works with up to 7 items. If more than 7 items exist, then the drawer will be displayed as empty.

Constant Value: 0 (0x00000000)

Public constructors

WearableNavigationDrawerView

added in version 26.1.0
WearableNavigationDrawerView (Context context)

Parameters
context Context

WearableNavigationDrawerView

added in version 26.1.0
WearableNavigationDrawerView (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

WearableNavigationDrawerView

added in version 26.1.0
WearableNavigationDrawerView (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

WearableNavigationDrawerView

added in version 26.1.0
WearableNavigationDrawerView (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

defStyleRes int

Public methods

addOnItemSelectedListener

added in version 26.1.0
void addOnItemSelectedListener (WearableNavigationDrawerView.OnItemSelectedListener listener)

Add an WearableNavigationDrawerView.OnItemSelectedListener that will be notified when the user selects an item.

Parameters
listener WearableNavigationDrawerView.OnItemSelectedListener

canScrollHorizontally

boolean canScrollHorizontally (int direction)

Parameters
direction int

Returns
boolean

getNavigationStyle

added in version 26.1.0
int getNavigationStyle ()

Returns the style this drawer is using, either SINGLE_PAGE or MULTI_PAGE.

Returns
int

onDrawerClosed

added in version 26.1.0
void onDrawerClosed ()

Called when the drawer has settled in a completely closed state. This is analogous to onDrawerClosed(WearableDrawerLayout, WearableDrawerView).

onDrawerOpened

added in version 26.1.0
void onDrawerOpened ()

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

onInterceptTouchEvent

boolean onInterceptTouchEvent (MotionEvent ev)

Parameters
ev MotionEvent

Returns
boolean

removeOnItemSelectedListener

added in version 26.1.0
void removeOnItemSelectedListener (WearableNavigationDrawerView.OnItemSelectedListener listener)

Remove an WearableNavigationDrawerView.OnItemSelectedListener.

Parameters
listener WearableNavigationDrawerView.OnItemSelectedListener

setAdapter

added in version 26.1.0
void setAdapter (WearableNavigationDrawerView.WearableNavigationDrawerAdapter adapter)

Set a WearableNavigationDrawerView.WearableNavigationDrawerAdapter that will supply data for this drawer.

Parameters
adapter WearableNavigationDrawerView.WearableNavigationDrawerAdapter

setCurrentItem

added in version 26.1.0
void setCurrentItem (int index, 
                boolean smoothScrollTo)

Changes which index is selected. onItemSelected(int) will be called when the specified index is reached, but it won't be called for items between the current index and the destination index.

Parameters
index int

smoothScrollTo boolean

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)