Card

public class Card

The Card class provides the model for a Glass-themed card.

You build a card with a set of desired properties and the system generates a proper view layout for the card.

See Creating Glass-styled cards for more information and sample code.

General usage

  1. Create a Card object.
  2. Set properties of the card with the setXXX methods.
  3. Convert the card to a view with getView().

Nested Classes

enum Card.ImageLayout Defines image layouts for a card. 

Public Constructors

Card(Context context)

Public Methods

Card
addImage(Bitmap imageBitmap)
Card
addImage(Drawable imageDrawable)
Card
addImage(int imageId)
void
CharSequence
Drawable
getImage(int n)
int
Card.ImageLayout
int
CharSequence
CharSequence
View
getView(View convertView, ViewGroup parent)
View
static int
Card
Card
setFootnote(int footnoteId)
Card
Card
setText(int textId)
Card
Card
setTimestamp(int timestampId)
Card

Inherited Methods

Public Constructors

public Card (Context context)

Public Methods

public Card addImage (Bitmap imageBitmap)

Adds an image defined as a Bitmap to the card.

Parameters
imageBitmap the bitmap of the image to add
Returns
  • this object for call chaining

public Card addImage (Drawable imageDrawable)

Adds an image defined as a Drawable to the card.

Parameters
imageDrawable the drawable of the image to add
Returns
  • this object for call chaining

public Card addImage (int imageId)

Adds an image defined as a resource ID to the card.

Parameters
imageId the resource ID of the image to add
Returns
  • this object for call chaining

public void clearImages ()

Clears all previously added images associated with the card.

public CharSequence getFootnote ()

Returns footnote text for card.

public Drawable getImage (int n)

Returns the n-th image associated with the card, where 0 <= n < getNumberofImages().

Returns
  • Drawable representation of the n-th image

public int getImageCount ()

Returns the number of images associated with the card.

public Card.ImageLayout getImageLayout ()

Returns the image layout for card.

public int getItemViewType ()

Returns the view type of this particular card.

Useful in combination with an adapter. See Adapter.getItemViewType(int position).

public CharSequence getText ()

Returns main text for card.

public CharSequence getTimestamp ()

Returns timestamp text for card.

public View getView (View convertView, ViewGroup parent)

Returns a View representation of this card.

Useful in combination with an adapter. See Adapter.getView(int position, View convertView, ViewGroup parent)).

Parameters
convertView an old view to reuse, if possible; can be null Note: if this view does not have the right type, this method creates a new view
parent that this view will eventually be attached to, maybe null

public View getView ()

Returns a View representation of this card.

public static int getViewTypeCount ()

Returns the total number of view types cards can take.

Useful in combination with an adapter. See Adapter.getViewTypeCount().

public Card setFootnote (CharSequence footnote)

Sets footnote text for card.

Parameters
footnote the footnote text for this card
Returns
  • this object for call chaining

public Card setFootnote (int footnoteId)

Sets footnote text defined by resource ID for card.

Parameters
footnoteId the footnote text resource ID for this card
Returns
  • this object for call chaining

public Card setImageLayout (Card.ImageLayout imageLayout)

Sets the image layout for the card.

Parameters
imageLayout defines desired image layout
Returns
  • this object for call chaining

public Card setText (int textId)

Sets main text defined by resource ID for card.

Parameters
textId main text resource ID for this card
Returns
  • this object for call chaining

public Card setText (CharSequence text)

Sets main text for card.

Parameters
text main text for this card
Returns
  • this object for call chaining

public Card setTimestamp (int timestampId)

Sets timestamp text defined by resource ID for card.

Parameters
timestampId the timestamp text resource ID for this card
Returns
  • this object for call chaining

public Card setTimestamp (CharSequence timestamp)

Sets timestamp text for card.

Parameters
timestamp the timestamp text for this card
Returns
  • this object for call chaining

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.