lightbulb_outline Help shape the future of the Google Play Console, Android Studio, and Firebase. Start survey

WearableListView

public class WearableListView
extends RecyclerView

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.support.v7.widget.RecyclerView
         ↳ android.support.wearable.view.WearableListView


This class is deprecated.
for centering and snapping your list items consider using the WearableRecyclerView supported by a SnapHelper or the LinearSnapHelper. For scaling and otherwise modifying the list items based on their location on the screen consider using an WearableRecyclerView.ChildLayoutManager or the CurvedChildLayoutManager.

An alternative version of ListView that is optimized for ease of use on small screen wearable devices. It displays a vertically scrollable list of items, and automatically snaps to the nearest item when the user stops scrolling.

For a quick start, you will need to implement a subclass of WearableListView.Adapter, which will create and bind your views to the WearableListView.ViewHolder objects. If you want to add more visual treatment to your views when they become the central items of the WearableListView, have them implement the WearableListView.OnCenterProximityListener interface.

Summary

Nested classes

class WearableListView.Adapter

This class is deprecated. Use WearableListView.GenericAdapter instead.  

interface WearableListView.ClickListener

Interface for listening for click events on WearableListView. 

class WearableListView.GenericAdapter<T extends WearableListView.ViewHolder>

Base class for adapters providing data for the WearableListView supporting generics. 

interface WearableListView.OnCenterProximityListener

Interface for receiving callbacks when WearableListView children become or cease to be the central item. 

interface WearableListView.OnCentralPositionChangedListener

A listener interface that can be added to the WearableListView to get notified when the central item is changed. 

interface WearableListView.OnScrollListener

Interface for listening to WearableListView content scrolling. 

class WearableListView.ViewHolder

Wrapper around items displayed in the list view. 

Inherited constants

From class android.support.v7.widget.RecyclerView
From class android.view.ViewGroup
From class android.view.View

Inherited fields

From class android.view.View

Public constructors

WearableListView(Context context)
WearableListView(Context context, AttributeSet attrs)
WearableListView(Context context, AttributeSet attrs, int defStyleAttr)

Public methods

void addOnCentralPositionChangedListener(WearableListView.OnCentralPositionChangedListener listener)

Adds a listener that will be called when the central item of the list changes.

void addOnScrollListener(WearableListView.OnScrollListener listener)

Adds a listener that will be called when the content of the list view is scrolled.

void animateToCenter()

Automatically starts an animation that snaps the list to center on the element closest to the middle.

boolean fling(int velocityX, int velocityY)
int getBaseline()
int getCentralViewTop()

Returns top of the central View in the list when such view is fully centered.

WearableListView.ViewHolder getChildViewHolder(View child)
boolean getMaximizeSingleItem()

Determines if, when there is only one item in the WearableListView, that the single item is laid out so that it's height fills the entire WearableListView.

boolean isAtTop()
boolean isGestureNavigationEnabled()

Determines if navigation of list with wrist gestures is enabled.

boolean onGenericMotionEvent(MotionEvent ev)
boolean onInterceptTouchEvent(MotionEvent event)
boolean onKeyDown(int keyCode, KeyEvent event)
boolean onTouchEvent(MotionEvent event)
void removeOnCentralPositionChangedListener(WearableListView.OnCentralPositionChangedListener listener)

Removes a listener that would be called when the central item of the list changes.

void removeOnScrollListener(WearableListView.OnScrollListener listener)

Removes listener for scroll events.

void resetLayoutManager()

Clears the state of the layout manager that positions list items.

void setAdapter(Adapter adapter)
void setClickListener(WearableListView.ClickListener clickListener)

Adds a listener that will be called when the user taps on the WearableListView or its items.

void setEnableGestureNavigation(boolean enabled)

Sets whether navigation of list with wrist gestures is enabled.

void setGreedyTouchMode(boolean greedy)

Controls whether WearableListView should intercept all touch events and also prevent the parent from receiving them.

void setInitialOffset(int top)

By default the first element of the list is initially positioned in the center of the screen.

void setMaximizeSingleItem(boolean maximizeSingleItem)

When set to true, if there is only one item in the WearableListView, it will fill the entire WearableListView.

void smoothScrollToPosition(int position, RecyclerView.SmoothScroller smoothScroller)

Protected methods

void onAttachedToWindow()
void onDetachedFromWindow()

Inherited methods

From class android.support.v7.widget.RecyclerView
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.support.v4.view.ScrollingView
From interface android.support.v4.view.NestedScrollingChild2
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
From interface android.support.v4.view.NestedScrollingChild

Public constructors

WearableListView

WearableListView (Context context)

Parameters
context Context

WearableListView

WearableListView (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

WearableListView

WearableListView (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

Public methods

addOnCentralPositionChangedListener

void addOnCentralPositionChangedListener (WearableListView.OnCentralPositionChangedListener listener)

Adds a listener that will be called when the central item of the list changes.

Parameters
listener WearableListView.OnCentralPositionChangedListener

addOnScrollListener

void addOnScrollListener (WearableListView.OnScrollListener listener)

Adds a listener that will be called when the content of the list view is scrolled.

Parameters
listener WearableListView.OnScrollListener

animateToCenter

void animateToCenter ()

Automatically starts an animation that snaps the list to center on the element closest to the middle.

fling

boolean fling (int velocityX, 
                int velocityY)

Parameters
velocityX int

velocityY int

Returns
boolean

getBaseline

int getBaseline ()

Returns
int the position of the center child's baseline; -1 if no center child exists or if the center child does not return a valid baseline.

getCentralViewTop

int getCentralViewTop ()

Returns top of the central View in the list when such view is fully centered.

This is a more or a less a static value that you can use to align other views with the central one.

Returns
int

getChildViewHolder

WearableListView.ViewHolder getChildViewHolder (View child)

Parameters
child View

Returns
WearableListView.ViewHolder

getMaximizeSingleItem

boolean getMaximizeSingleItem ()

Determines if, when there is only one item in the WearableListView, that the single item is laid out so that it's height fills the entire WearableListView.

Returns
boolean

isAtTop

boolean isAtTop ()

Returns
boolean true if the list is scrolled all the way to the top.

isGestureNavigationEnabled

boolean isGestureNavigationEnabled ()

Determines if navigation of list with wrist gestures is enabled.

Returns
boolean

onGenericMotionEvent

boolean onGenericMotionEvent (MotionEvent ev)

Parameters
ev MotionEvent

Returns
boolean

onInterceptTouchEvent

boolean onInterceptTouchEvent (MotionEvent event)

Parameters
event MotionEvent

Returns
boolean

onKeyDown

boolean onKeyDown (int keyCode, 
                KeyEvent event)

Parameters
keyCode int

event KeyEvent

Returns
boolean

onTouchEvent

boolean onTouchEvent (MotionEvent event)

Parameters
event MotionEvent

Returns
boolean

removeOnCentralPositionChangedListener

void removeOnCentralPositionChangedListener (WearableListView.OnCentralPositionChangedListener listener)

Removes a listener that would be called when the central item of the list changes.

Parameters
listener WearableListView.OnCentralPositionChangedListener

removeOnScrollListener

void removeOnScrollListener (WearableListView.OnScrollListener listener)

Removes listener for scroll events.

Parameters
listener WearableListView.OnScrollListener

resetLayoutManager

void resetLayoutManager ()

Clears the state of the layout manager that positions list items.

setAdapter

void setAdapter (Adapter adapter)

Parameters
adapter Adapter

setClickListener

void setClickListener (WearableListView.ClickListener clickListener)

Adds a listener that will be called when the user taps on the WearableListView or its items.

Parameters
clickListener WearableListView.ClickListener

setEnableGestureNavigation

void setEnableGestureNavigation (boolean enabled)

Sets whether navigation of list with wrist gestures is enabled.

Parameters
enabled boolean

setGreedyTouchMode

void setGreedyTouchMode (boolean greedy)

Controls whether WearableListView should intercept all touch events and also prevent the parent from receiving them.

Parameters
greedy boolean: If true it will intercept all touch events.

setInitialOffset

void setInitialOffset (int top)

By default the first element of the list is initially positioned in the center of the screen. This method allows the developer to specify a different offset, e.g. to hide the WearableListView before the user is allowed to use it.

Parameters
top int: How far the elements should be pushed down.

setMaximizeSingleItem

void setMaximizeSingleItem (boolean maximizeSingleItem)

When set to true, if there is only one item in the WearableListView, it will fill the entire WearableListView. When set to false, the default behavior will be used and the single item will fill only a third of the screen.

Parameters
maximizeSingleItem boolean

smoothScrollToPosition

void smoothScrollToPosition (int position, 
                RecyclerView.SmoothScroller smoothScroller)

Parameters
position int

smoothScroller RecyclerView.SmoothScroller

Protected methods

onAttachedToWindow

void onAttachedToWindow ()

onDetachedFromWindow

void onDetachedFromWindow ()