GridRowBuilder.CellBuilder
public 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 constructors
CellBuilder
public CellBuilder()
Create a builder which will construct a slice displayed as a cell in a grid.
Public methods
addImage
public @NonNull GridRowBuilder.CellBuilder addImage(@NonNull IconCompat image, int imageMode)
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 | |
|---|---|
@NonNull IconCompat image |
the image to display in the cell. |
int imageMode |
the mode that image should be displayed in. |
| See also | |
|---|---|
ICON_IMAGE |
|
SMALL_IMAGE |
|
LARGE_IMAGE |
addImage
public @NonNull GridRowBuilder.CellBuilder addImage(@Nullable IconCompat image, int imageMode, boolean isLoading)
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 | |
|---|---|
@Nullable IconCompat image |
the image to display in the cell. |
int imageMode |
the mode that image should be displayed in. |
boolean isLoading |
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
public @NonNull GridRowBuilder.CellBuilder addOverlayText(@NonNull CharSequence text)
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
public @NonNull GridRowBuilder.CellBuilder addOverlayText(@Nullable CharSequence text, boolean isLoading)
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 | |
|---|---|
boolean isLoading |
indicates whether the app is doing work to load the added content in the background or not. |
addText
public @NonNull GridRowBuilder.CellBuilder addText(@NonNull CharSequence text)
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
public @NonNull GridRowBuilder.CellBuilder addText(@Nullable CharSequence text, boolean isLoading)
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 | |
|---|---|
boolean isLoading |
indicates whether the app is doing work to load the added content in the background or not. |
addTitleText
public @NonNull GridRowBuilder.CellBuilder addTitleText(@NonNull CharSequence text)
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
public @NonNull GridRowBuilder.CellBuilder addTitleText(@Nullable CharSequence text, boolean isLoading)
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 | |
|---|---|
boolean isLoading |
indicates whether the app is doing work to load the added content in the background or not. |
setContentDescription
public @NonNull GridRowBuilder.CellBuilder setContentDescription(@NonNull CharSequence description)
Sets the content description for this cell.
setContentIntent
public @NonNull GridRowBuilder.CellBuilder setContentIntent(@NonNull RemoteCallback callback)
Sets the action to be invoked if the user taps on this cell in the row.
setContentIntent
public @NonNull GridRowBuilder.CellBuilder setContentIntent(@NonNull PendingIntent intent)
Sets the action to be invoked if the user taps on this cell in the row.
setSliceAction
public @NonNull GridRowBuilder.CellBuilder setSliceAction(@NonNull SliceAction action)
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.