Android APIs
public class

SparseArrayObjectAdapter

extends ObjectAdapter
java.lang.Object
   ↳ android.support.v17.leanback.widget.ObjectAdapter
     ↳ android.support.v17.leanback.widget.SparseArrayObjectAdapter

Class Overview

An ObjectAdapter implemented with a SparseArray. This class maintains an array of objects where each object is associated with an integer key which determines its order relative to other objects.

Summary

[Expand]
Inherited Constants
From class android.support.v17.leanback.widget.ObjectAdapter
Public Constructors
SparseArrayObjectAdapter(PresenterSelector presenterSelector)
Construct an adapter with the given PresenterSelector.
SparseArrayObjectAdapter(Presenter presenter)
Construct an adapter with the given Presenter.
SparseArrayObjectAdapter()
Construct an adapter.
Public Methods
void clear()
Removes all items from this adapter, leaving it empty.
void clear(int key)
Clears the given key and associated item from the adapter.
Object get(int position)
Returns the item for the given position.
int indexOf(Object item)
Returns the index for the given item in the adapter.
int indexOf(int key)
Returns the index for the given key in the adapter.
Object lookup(int key)
Returns the object for the given key, or null if no mapping for that key exists.
void notifyArrayItemRangeChanged(int positionStart, int itemCount)
Notify that the content of a range of items changed.
void set(int key, Object item)
Sets the item for the given key.
int size()
Returns the number of items in the adapter.
[Expand]
Inherited Methods
From class android.support.v17.leanback.widget.ObjectAdapter
From class java.lang.Object

Public Constructors

public SparseArrayObjectAdapter (PresenterSelector presenterSelector)

Construct an adapter with the given PresenterSelector.

public SparseArrayObjectAdapter (Presenter presenter)

Construct an adapter with the given Presenter.

public SparseArrayObjectAdapter ()

Construct an adapter.

Public Methods

public void clear ()

Removes all items from this adapter, leaving it empty.

public void clear (int key)

Clears the given key and associated item from the adapter.

Parameters
key The key to be cleared.

public Object get (int position)

Returns the item for the given position.

public int indexOf (Object item)

Returns the index for the given item in the adapter.

Parameters
item The item to find in the array.
Returns
  • Index of the item, or a negative value if not found.

public int indexOf (int key)

Returns the index for the given key in the adapter.

Parameters
key The key to find in the array.
Returns
  • Index of the item, or a negative value if not found.

public Object lookup (int key)

Returns the object for the given key, or null if no mapping for that key exists.

public void notifyArrayItemRangeChanged (int positionStart, int itemCount)

Notify that the content of a range of items changed. Note that this is not same as items being added or removed.

Parameters
positionStart The position of first item that has changed.
itemCount The count of how many items have changed.

public void set (int key, Object item)

Sets the item for the given key.

Parameters
key The key associated with the item.
item The item associated with the key.

public int size ()

Returns the number of items in the adapter.