Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.
added in version 1.0.0
belongs to Maven artifact androidx.wear:wear:1.0.0-rc01

WearableNavigationDrawerView

public class WearableNavigationDrawerView
extends WearableDrawerView

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ androidx.wear.widget.drawer.WearableDrawerView
           ↳ androidx.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

Inherited fields

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

Constants

MULTI_PAGE

added in version 1.0.0
public static final 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 1.0.0
public static final 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 1.0.0
public WearableNavigationDrawerView (Context context)

Parameters
context Context

WearableNavigationDrawerView

added in version 1.0.0
public WearableNavigationDrawerView (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

WearableNavigationDrawerView

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

Parameters
context Context

attrs AttributeSet

defStyleAttr int

WearableNavigationDrawerView

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

Parameters
context Context

attrs AttributeSet

defStyleAttr int

defStyleRes int

Public methods

addOnItemSelectedListener

added in version 1.0.0
public void addOnItemSelectedListener (WearableNavigationDrawerView.OnItemSelectedListener listener)

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

Parameters
listener WearableNavigationDrawerView.OnItemSelectedListener

canScrollHorizontally

public boolean canScrollHorizontally (int direction)

Parameters
direction int

Returns
boolean

getNavigationStyle

added in version 1.0.0
public int getNavigationStyle ()

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

Returns
int

onDrawerClosed

added in version 1.0.0
public void onDrawerClosed ()

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

onDrawerOpened

added in version 1.0.0
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).

onInterceptTouchEvent

public boolean onInterceptTouchEvent (MotionEvent ev)

Parameters
ev MotionEvent

Returns
boolean

removeOnItemSelectedListener

added in version 1.0.0
public void removeOnItemSelectedListener (WearableNavigationDrawerView.OnItemSelectedListener listener)

Remove an WearableNavigationDrawerView.OnItemSelectedListener.

Parameters
listener WearableNavigationDrawerView.OnItemSelectedListener

setAdapter

added in version 1.0.0
public void setAdapter (WearableNavigationDrawerView.WearableNavigationDrawerAdapter adapter)

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

Parameters
adapter WearableNavigationDrawerView.WearableNavigationDrawerAdapter

setCurrentItem

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

Changes which index is selected. WearableNavigationDrawerView.OnItemSelectedListener.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