GridRowBuilder.CellBuilder
class GridRowBuilder.CellBuilder
CellBuilderDsl |
Helper class annotated with @SliceMarker, which is annotated with @DslMarker. |
Builder to construct a cell. A cell can be added as an item to GridRowBuilder via addCell.
A cell supports up to two lines of text and one image. Content added to a cell will be displayed in the order that the content is added to it. For example, the below code would construct a cell with "First text", and image below it, and then "Second text" below the image.
CellBuilder cb = new CellBuilder(parent, sliceUri); cb.addText("First text") .addImage(middleIcon) .addText("Second text");
A cell supports a couple of image types:
ICON_IMAGE- icon images are expected to be tintable and are shown at a standard icon size.SMALL_IMAGE- small images are not tinted and are shown at a small size.LARGE_IMAGE- large images are not tinted and are shown as large as they can be, in aCENTER_CROP
| See also | |
|---|---|
addCell |
|
addGridRow |
|
ICON_IMAGE |
|
SMALL_IMAGE |
|
ICON_IMAGE |
Summary
Public constructors |
|---|
|
Create a builder which will construct a slice displayed as a cell in a grid. |
Public functions |
|
|---|---|
GridRowBuilder.CellBuilder |
addImage(image: IconCompat, imageMode: Int)Adds an image to the cell. |
GridRowBuilder.CellBuilder |
addImage(image: IconCompat?, imageMode: Int, isLoading: Boolean)Adds an image to the cell. |
GridRowBuilder.CellBuilder |
addOverlayText(text: CharSequence)Adds text to the cell. |
GridRowBuilder.CellBuilder |
addOverlayText(text: CharSequence?, isLoading: Boolean)Adds text to the cell. |
GridRowBuilder.CellBuilder |
addText(text: CharSequence)Adds text to the cell. |
GridRowBuilder.CellBuilder |
addText(text: CharSequence?, isLoading: Boolean)Adds text to the cell. |
GridRowBuilder.CellBuilder |
addTitleText(text: CharSequence)Adds text to the cell. |
GridRowBuilder.CellBuilder |
addTitleText(text: CharSequence?, isLoading: Boolean)Adds text to the cell. |
GridRowBuilder.CellBuilder |
setContentDescription(description: CharSequence)Sets the content description for this cell. |
GridRowBuilder.CellBuilder |
setContentIntent(callback: RemoteCallback)Sets the action to be invoked if the user taps on this cell in the row. |
GridRowBuilder.CellBuilder |
setContentIntent(intent: PendingIntent)Sets the action to be invoked if the user taps on this cell in the row. |
GridRowBuilder.CellBuilder |
setSliceAction(action: SliceAction)Sets the SliceAction for the cell. |
Public constructors
CellBuilder
CellBuilder()
Create a builder which will construct a slice displayed as a cell in a grid.
Public functions
addImage
fun addImage(image: IconCompat, imageMode: Int): GridRowBuilder.CellBuilder
Adds an image to the cell. There can be at most one image, the first one added will be used, others will be ignored.
| Parameters | |
|---|---|
image: IconCompat |
the image to display in the cell. |
imageMode: Int |
the mode that image should be displayed in. |
| See also | |
|---|---|
ICON_IMAGE |
|
SMALL_IMAGE |
|
LARGE_IMAGE |
addImage
fun addImage(image: IconCompat?, imageMode: Int, isLoading: Boolean): GridRowBuilder.CellBuilder
Adds an image to the cell. There can be at most one image, the first one added will be used, others will be ignored.
Use this method to specify content that will appear in the template once it's been loaded.
| Parameters | |
|---|---|
image: IconCompat? |
the image to display in the cell. |
imageMode: Int |
the mode that image should be displayed in. |
isLoading: Boolean |
indicates whether the app is doing work to load the added content in the background or not. |
| See also | |
|---|---|
ICON_IMAGE |
|
SMALL_IMAGE |
|
LARGE_IMAGE |
addOverlayText
fun addOverlayText(text: CharSequence): GridRowBuilder.CellBuilder
Adds text to the cell. Text added with this method will be overlaid in the image in the cell. There can be only one overlay text, the first added will be used, others will be ignored.
addOverlayText
fun addOverlayText(text: CharSequence?, isLoading: Boolean): GridRowBuilder.CellBuilder
Adds text to the cell. Text added with this method will be overlaid in the image in the cell. There can be only one overlay text, the first added will be used, others will be ignored.
Use this method to specify content that will appear in the template once it's been loaded.
| Parameters | |
|---|---|
isLoading: Boolean |
indicates whether the app is doing work to load the added content in the background or not. |
addText
fun addText(text: CharSequence): GridRowBuilder.CellBuilder
Adds text to the cell. There can be at most two text items, the first two added will be used, others will be ignored.
addText
fun addText(text: CharSequence?, isLoading: Boolean): GridRowBuilder.CellBuilder
Adds text to the cell. There can be at most two text items, the first two added will be used, others will be ignored.
Use this method to specify content that will appear in the template once it's been loaded.
| Parameters | |
|---|---|
isLoading: Boolean |
indicates whether the app is doing work to load the added content in the background or not. |
addTitleText
fun addTitleText(text: CharSequence): GridRowBuilder.CellBuilder
Adds text to the cell. Text added with this method will be styled as a title. There can be at most two text items, the first two added will be used, others will be ignored.
addTitleText
fun addTitleText(text: CharSequence?, isLoading: Boolean): GridRowBuilder.CellBuilder
Adds text to the cell. Text added with this method will be styled as a title. There can be at most two text items, the first two added will be used, others will be ignored.
Use this method to specify content that will appear in the template once it's been loaded.
| Parameters | |
|---|---|
isLoading: Boolean |
indicates whether the app is doing work to load the added content in the background or not. |
setContentDescription
fun setContentDescription(description: CharSequence): GridRowBuilder.CellBuilder
Sets the content description for this cell.
setContentIntent
fun setContentIntent(callback: RemoteCallback): GridRowBuilder.CellBuilder
Sets the action to be invoked if the user taps on this cell in the row.
setContentIntent
fun setContentIntent(intent: PendingIntent): GridRowBuilder.CellBuilder
Sets the action to be invoked if the user taps on this cell in the row.
setSliceAction
fun setSliceAction(action: SliceAction): GridRowBuilder.CellBuilder
Sets the SliceAction for the cell. It could be an action or a toggle button or a date/time picker. The actionTitle and icon image of the SliceAction will only be used when there is no other text or image in the cell.