public class

WearableListView

extends RecyclerView

Note: The Wearable Support Library classes under the android.support.wearable package are subject to change. For the full Android API reference, see Reference.

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

Class Overview

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 Base class for adapters providing data for the WearableListView. 
interface WearableListView.ClickListener Interface for listening for click events on WearableListView. 
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. 
[Expand]
Inherited Constants
From class android.support.v7.widget.RecyclerView
From class android.view.ViewGroup
From class android.view.View
[Expand]
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 onInterceptTouchEvent(MotionEvent 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 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.
[Expand]
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.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

Public Constructors

public WearableListView (Context context)

public WearableListView (Context context, AttributeSet attrs)

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

Public Methods

public void addOnCentralPositionChangedListener (WearableListView.OnCentralPositionChangedListener listener)

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

public void addOnScrollListener (WearableListView.OnScrollListener listener)

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

public void animateToCenter ()

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

public boolean fling (int velocityX, int velocityY)

public int getBaseline ()

Returns
  • 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.

public 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.

public WearableListView.ViewHolder getChildViewHolder (View child)

public 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.

public boolean onInterceptTouchEvent (MotionEvent event)

public boolean onTouchEvent (MotionEvent event)

public void removeOnCentralPositionChangedListener (WearableListView.OnCentralPositionChangedListener listener)

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

public void removeOnScrollListener (WearableListView.OnScrollListener listener)

Removes listener for scroll events.

public void resetLayoutManager ()

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

public void setAdapter (Adapter adapter)

public void setClickListener (WearableListView.ClickListener clickListener)

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

public void setGreedyTouchMode (boolean greedy)

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

Parameters
greedy If true it will intercept all touch events.

public 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 How far the elements should be pushed down.

public 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.