Class CardBuilder Stay organized with collections Save and categorize content based on your preferences.
Page Summary
CardBuilder is used to build Card objects.
You can add card actions and sections to a Card using the builder.
The build() method finalizes and validates the Card object.
Various methods allow setting the card's display style, footer, header, name, and peek card header.
A builder forCard objects.
Methods
| Method | Return type | Brief description |
|---|---|---|
add | Card | Adds aCard to this Card. |
add | Card | Adds an expression data to this card. |
add | Card | Adds a section to this card. |
build() | Card | Builds the current card and validates it. |
set | Card | Sets the display style for this card. |
set | Card | Sets a fixed footer for this card. |
set | Card | Sets the header for this card. |
set | Card | Sets the name for this card. |
set | Card | Sets the peek card header. |
Detailed documentation
addCardAction(cardAction)
Adds aCard to this Card.
Parameters
| Name | Type | Description |
|---|---|---|
card | Card | TheCard to use. |
Return
Card — This object, for chaining.
addExpressionData(expressionData)
Adds an expression data to this card.
The ExpressionData defines the CEL logic and condition as well as what event to trigger whena condition is satisfied.
Parameters
| Name | Type | Description |
|---|---|---|
expression | Expression | TheExpression to use. |
Return
Card — This object, for chaining.
addSection(section)
Adds a section to this card. You can't add more than 100 sections to a card.
Parameters
| Name | Type | Description |
|---|---|---|
section | Card | TheCard to use. |
Return
Card — This object, for chaining.
build()
setDisplayStyle(displayStyle)
Sets the display style for this card.
If the display style is set toDisplay, the card is shown by replacingthe view of top card in the card stack.
If the display style is set toDisplay, the header of the card appears atthe bottom of the sidebar, partially covering the current top card of the stack. Clicking theheader pops the card into the card stack. If the card has no header, a generated header is usedinstead.
Display only works for card returned from contextual trigger function.
Parameters
| Name | Type | Description |
|---|---|---|
display | Display | TheDisplay to set. |
Return
Card — This object, for chaining.
setFixedFooter(fixedFooter)
Sets a fixed footer for this card.
Parameters
| Name | Type | Description |
|---|---|---|
fixed | Fixed | TheFixed to use. |
Return
Card — This object, for chaining.
setHeader(cardHeader)
Sets the header for this card.
Parameters
| Name | Type | Description |
|---|---|---|
card | Card | TheCard to use. |
Return
Card — This object, for chaining.
setName(name)
Sets the name for this card. The name can be used fornavigation.
Parameters
| Name | Type | Description |
|---|---|---|
name | String | The name. |
Return
Card — This object, for chaining.
setPeekCardHeader(peekCardHeader)
Sets the peek card header.
The peek card is set on the first card returned from a contextual trigger function. It isused as a descriptive placeholder widget so that users can navigate from a homepage stack tothe contextual stack.
Parameters
| Name | Type | Description |
|---|---|---|
peek | Card | TheCard to set. |
Return
Card — This object, for chaining.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-03 UTC.