A special form of a BaseAdapter
.
Use this in combination with a CardScrollView
to implement horizontally
scrolling views, also referred to as cards. This adapter binds (possibly dynamic)
data to the CardScrollView
by retrieving the data (if needed) and converting
each data item into a card. Each card visually represents a certain Object
item.
To be consistent with the Glass UI, create cards with the
CardBuilder
class, which supports several
content layouts. If you require more flexibility, you can create your
own XML layouts or create views programmatically.
See Scrolling cards in activities for more information.
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract int |
getCount()
|
||||||||||
int | |||||||||||
abstract Object |
getItem(int position)
|
||||||||||
long |
getItemId(int position)
|
||||||||||
int |
getItemViewType(int position)
|
||||||||||
abstract int |
getPosition(Object item)
|
||||||||||
abstract View | |||||||||||
int |
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Constructors
public CardScrollAdapter ()
Public Methods
public abstract int getCount ()
public int getHomePosition ()
Returns the home position. The default implementation simply assumes position 0 is the home position, but the user can override this method to move the home position to a different card.
For example, the home position of the Glass timeline is the clock card, and other cards can be located both to the left and to the right of it.
Returns
- the position of the item that represents the home position
public long getItemId (int position)
The default implementation simply assigns the card's position as row identifier
and assumes this property holds even across data changes. When each data item
has a truly unique row identifier, users can override this method to return the
real row identifier and override hasStableIds()
to return true. By doing
so, the card scroller is more likely to maintain its view on selected cards across
data changes.
public int getItemViewType (int position)
public abstract int getPosition (Object item)
Finds the position of the given item.
Parameters
item | the item to find |
---|
Returns
- the position of the given item,
or
INVALID_POSITION
if the item cannot be found
public abstract View getView (int position, View convertView, ViewGroup parent)
public int getViewTypeCount ()
The default implementation returns 0 to signal lack of recycling. Users can override this
method (only called once when adapter is set) and getItemViewType(int)
to enable view recycling.