Added in API level XE21
The CardBuilder
class helps with building Glass-themed cards with various layouts.
See Creating Glass-styled cards for more information and sample code.
CardBuilder
object, passing the desired CardBuilder.Layout
to the constructor.add/set*
family of methods.View
by calling getView()
or get a RemoteViews
object with getRemoteViews()
.When using EMBED_INSIDE
CardBuilder
makes no distinction between different embedded layouts when recycling views. If you have two CardBuilder
instances with EMBED_INSIDE
but one has layout A and the other has layout B, they will be treated as the same by CardBuilder
.
If this behavior is undesirable (for example, when using a CardScrollAdapter
with different embedded layouts), you must distinguish them by returning different view types from getItemViewType(int)
so that the recycler only sends you convertView
s with nested layouts that you expect for a particular item.
If you need to support cards with multiple embedded layouts alongside the built-in layouts, we recommend that you return view types numbered getViewTypeCount()
, CardBuilder.getViewTypeCount() + 1
, and so on.
Nested Classes | ||
---|---|---|
enum | CardBuilder.Layout | Defines the visual layouts for cards. |
Public Constructors | |
---|---|
CardBuilder(Context context, CardBuilder.Layout layout) |
Inherited Methods | |
---|---|
From class java.lang.Object | |
Object | clone() |
boolean | equals(Object arg0) |
void | finalize() |
final Class<?> | getClass() |
int | hashCode() |
final void | notify() |
final void | notifyAll() |
String | toString() |
final void | wait() |
final void | wait(long arg0, int arg1) |
final void | wait(long arg0) |
Added in API level XE21
Constructs a new CardBuilder
.
Parameters | |
---|---|
context | the Context that will be used by the builder to create its views. |
layout | the desired layout for the card |
Added in API level XE21
Adds an image, specified as a Drawable
, to the card.
This method only applies to cards that are converted into views using getView()
. RemoteViews
built by CardBuilder
only support Bitmap
and resource-based images. Drawable
images on RemoteViews
are not supported.
Parameters | |
---|---|
imageDrawable | the Drawable image to add |
Added in API level XE21
Adds an image, specified as a Bitmap
, to the card.
Parameters | |
---|---|
imageBitmap | the Bitmap image to add |
Added in API level XE21
Adds an image, specified as a drawable resource, to the card.
Parameters | |
---|---|
imageId | the resource ID of the image to add |
Added in API level XE21
Clears all images that were previously added to the card.
Added in API level XE21
Returns the view type of this particular card.
Useful in combination with an adapter. See getItemViewType(int)
.
Added in API level XE21
Returns a RemoteViews
representation of this card.
Added in API level XE21
Returns a View
representation of this card.
Useful in combination with an adapter. See getView(int, View, ViewGroup)
.
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 |
Added in API level XE21
Returns a View
representation of this card.
Added in API level XE21
Returns the total number of view types cards can take.
Useful in combination with an adapter. See getViewTypeCount()
.
Added in API level XE22
Sets the attribution icon for the card using a Bitmap
.
Parameters | |
---|---|
iconBitmap | the Bitmap to use as the attribution icon |
Added in API level XE22
Sets the attribution icon for the card using a Drawable
.
This method only applies to cards that are converted into views using getView()
. RemoteViews
built by CardBuilder
only support Bitmap
and resource-based images. Drawable
images on RemoteViews
are not supported.
Parameters | |
---|---|
iconDrawable | the Drawable to use as the attribution icon |
Added in API level XE22
Sets the attribution icon for the card using a drawable resource.
Parameters | |
---|---|
iconId | the resource ID to use as the attribution icon |
Added in API level XE22
Sets the resource ID of the layout to embed in the card.
Parameters | |
---|---|
layoutResId | the resource ID of the layout to embed in the card |
Added in API level XE21
Sets the footnote text for the card.
Parameters | |
---|---|
footnote | the footnote text for this card |
Added in API level XE21
Sets the footnote text for the card using a string resource.
Parameters | |
---|---|
footnoteId | the footnote text resource ID for this card |
Added in API level XE21
Sets the heading text for the card.
Parameters | |
---|---|
heading | the heading text for this card |
Added in API level XE21
Sets the footnote text for the card using a string resource.
Parameters | |
---|---|
headingId | the heading text resource ID for this card |
Added in API level XE21
Sets the footnote text for the card.
Parameters | |
---|---|
footnote | the footnote text for this card |
Added in API level XE21
Sets the footnote text for the card using a string resource.
Parameters | |
---|---|
footnoteId | the footnote text resource ID for this card |
Added in API level XE21
Adds an image, specified as a Bitmap
, to the card.
Parameters | |
---|---|
iconBitmap | the Bitmap image to add |
Added in API level XE21
Adds an image, specified as a Drawable
, to the card.
This method only applies to cards that are converted into views using getView()
. RemoteViews
built by CardBuilder
only support Bitmap
and resource-based images. Drawable
images on RemoteViews
are not supported.
Parameters | |
---|---|
iconDrawable | the Drawable to use as the icon |
Added in API level XE21
Adds an image, specified as a drawable resource, to the card.
Parameters | |
---|---|
iconId | the resource ID to use as the icon |
Added in API level XE21
Sets the subheading text for the card.
Parameters | |
---|---|
subheading | the subheading text for this card |
Added in API level XE21
Sets the subheading text for the card using a string resource.
Parameters | |
---|---|
footnoteId | the footnote text resource ID for this card |
Added in API level XE21
Sets the main text for the card using a string resource.
Parameters | |
---|---|
textId | main text resource ID for this card |
Added in API level XE21
Sets the main text for the card.
Parameters | |
---|---|
text | main text for this card |
Added in API level XE21
Sets the timestamp text for the card.
Parameters | |
---|---|
timestamp | the timestamp text for this card |
Added in API level XE21
Sets the timestamp text for the card using a string resource.
Parameters | |
---|---|
timestampId | the timestamp text resource ID for this card |
Added in API level XE22
Shows an indicator if visible
is true that this card represents a stack of cards, rather than a single card.
Parameters | |
---|---|
visible | true to show the stack indicator, or false to hide it |
Portions of this page are reproduced from work created and shared by Google and used according to terms described in the Creative Commons 4.0 Attribution License.