android.support.wearable.view
Class WearableListView

java.lang.Object
  extended by RecyclerView
      extended by android.support.wearable.view.WearableListView

public class WearableListView
extends RecyclerView

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. The currently selected item in the list is always expanded to provide a larger touch target.

If you are using proguard in your project, you will need to update your proguard flags such that animations (expansion/contraction, snap-to-center) will work. These rules are:

 -keep class android.support.wearable.view.WearableListView {
   private void setScrollAnimator(int);
   private void setScrollVertically(int);
 }


Nested Class Summary
static class WearableListView.Adapter
          Base class for adapters providing data for the WearableListView.
static interface WearableListView.ClickListener
           
static interface WearableListView.Item
           
static interface WearableListView.OnScrollListener
           
static class WearableListView.ViewHolder
          Wrapper around items displayed in the list view.
 
Field Summary
static java.lang.String TAG
           
 
Constructor Summary
WearableListView(Context context)
           
WearableListView(Context context, AttributeSet attrs)
           
WearableListView(Context context, AttributeSet attrs, int defStyleAttr)
           
 
Method Summary
 void addOnScrollListener(WearableListView.OnScrollListener listener)
          Adds a listener that will be called when the content of the list view is scrolled.
 boolean fling(int velocityX, int velocityY)
           
 WearableListView.ViewHolder getChildViewHolder(View child)
           
 boolean onInterceptTouchEvent(MotionEvent event)
           
 void onScrolled(int dx, int dy)
           
 void onScrollStateChanged(int newState)
           
 boolean onTouchEvent(MotionEvent event)
           
 void removeOnScrollListener(WearableListView.OnScrollListener listener)
          Removes listener for scroll events.
 void resetLayoutManager()
          Clears state of the layout manager that positions list items.
 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 offset)
          By default the first element of the list is initially positioned in the center of the screen.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG

public static final java.lang.String TAG
See Also:
Constant Field Values
Constructor Detail

WearableListView

public WearableListView(Context context)

WearableListView

public WearableListView(Context context,
                        AttributeSet attrs)

WearableListView

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

resetLayoutManager

public void resetLayoutManager()
Clears state of the layout manager that positions list items.


setGreedyTouchMode

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.

setInitialOffset

public void setInitialOffset(int offset)
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:
offset - How far should the elements be pushed down.

onInterceptTouchEvent

public boolean onInterceptTouchEvent(MotionEvent event)

onTouchEvent

public boolean onTouchEvent(MotionEvent event)

onScrollStateChanged

public void onScrollStateChanged(int newState)

onScrolled

public void onScrolled(int dx,
                       int dy)

addOnScrollListener

public void addOnScrollListener(WearableListView.OnScrollListener listener)
Adds a listener that will be called when the content of the list view is scrolled.


removeOnScrollListener

public void removeOnScrollListener(WearableListView.OnScrollListener listener)
Removes listener for scroll events.


fling

public boolean fling(int velocityX,
                     int velocityY)

getChildViewHolder

public WearableListView.ViewHolder getChildViewHolder(View child)

setClickListener

public void setClickListener(WearableListView.ClickListener clickListener)
Adds a listener that will be called when the user taps on the WearableListView or its items.