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

This interface 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.  

class WearableListView.GenericAdapter<T extends WearableListView.ViewHolder>

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.  

interface WearableListView.OnCenterProximityListener

This interface 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.  

interface WearableListView.OnCentralPositionChangedListener

This interface 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.  

interface WearableListView.OnScrollListener

This interface 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.  

class WearableListView.ViewHolder

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.  

Inherited constants

Inherited fields

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

Public constructors

WearableListView

public WearableListView (Context context)

Parameters
context Context

WearableListView

public WearableListView (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

WearableListView

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

Parameters
context Context

attrs AttributeSet

defStyleAttr int

Public methods

addOnCentralPositionChangedListener

public 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

public 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

public void animateToCenter ()

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

fling

public boolean fling (int velocityX, 
                int velocityY)

Parameters
velocityX int

velocityY int

Returns
boolean

getBaseline

public 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

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.

Returns
int

getChildViewHolder

public WearableListView.ViewHolder getChildViewHolder (View child)

Parameters
child View

Returns
WearableListView.ViewHolder

getMaximizeSingleItem

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.

Returns
boolean

isAtTop

public boolean isAtTop ()

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

isGestureNavigationEnabled

public boolean isGestureNavigationEnabled ()

Determines if navigation of list with wrist gestures is enabled.

Returns
boolean

onGenericMotionEvent

public boolean onGenericMotionEvent (MotionEvent ev)

Parameters
ev MotionEvent

Returns
boolean

onInterceptTouchEvent

public boolean onInterceptTouchEvent (MotionEvent event)

Parameters
event MotionEvent

Returns
boolean

onKeyDown

public boolean onKeyDown (int keyCode, 
                KeyEvent event)

Parameters
keyCode int

event KeyEvent

Returns
boolean

onTouchEvent

public boolean onTouchEvent (MotionEvent event)

Parameters
event MotionEvent

Returns
boolean

removeOnCentralPositionChangedListener

public 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

public void removeOnScrollListener (WearableListView.OnScrollListener listener)

Removes listener for scroll events.

Parameters
listener WearableListView.OnScrollListener

resetLayoutManager

public void resetLayoutManager ()

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

setAdapter

public void setAdapter (Adapter adapter)

Parameters
adapter Adapter

setClickListener

public 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

public void setEnableGestureNavigation (boolean enabled)

Sets whether navigation of list with wrist gestures is enabled.

Parameters
enabled boolean

setGreedyTouchMode

public 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

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

setMaximizeSingleItem

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.

Parameters
maximizeSingleItem boolean

smoothScrollToPosition

public void smoothScrollToPosition (int position, 
                RecyclerView.SmoothScroller smoothScroller)

Parameters
position int

smoothScroller RecyclerView.SmoothScroller

Protected methods

onAttachedToWindow

protected void onAttachedToWindow ()

onDetachedFromWindow

protected void onDetachedFromWindow ()