The Google Glass Explorer Edition SDK is deprecated. This documentation is no longer being maintained. If you're interested in developing Glass solutions for enterprise clients, visit the Google Glass Enterprise Edition developer documentation.

CardScrollAdapter

Added in API level XE12

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
int
abstract Object
getItem(int position)
long
getItemId(int position)
int
getItemViewType(int position)
abstract int
abstract View
getView(int position, View convertView, ViewGroup parent)
int
Inherited Methods

Public Constructors

Added in API level XE12

public CardScrollAdapter ()

Public Methods

Added in API level XE12

public abstract int getCount ()

Added in API level XE12

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
Added in API level XE12

public abstract Object getItem (int position)

Added in API level XE12

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)

Added in API level XE16

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
Added in API level XE12

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.