CellBuilder
open class CellBuilder
kotlin.Any | |
↳ | androidx.slice.builders.GridRowBuilder.CellBuilder |
Builder to construct a cell. A cell can be added as an item to GridRowBuilder via GridRowBuilder#addCell(CellBuilder)
.
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:
ListBuilder#ICON_IMAGE
- icon images are expected to be tintable and are shown at a standard icon size.ListBuilder#SMALL_IMAGE
- small images are not tinted and are shown at a small size.ListBuilder#LARGE_IMAGE
- large images are not tinted and are shown as large as they can be, in aandroid.widget.ImageView.ScaleType#CENTER_CROP
Summary
Public constructors | |
---|---|
<init>() Create a builder which will construct a slice displayed as a cell in a grid. |
Public methods | |
---|---|
open GridRowBuilder.CellBuilder |
addImage(@NonNull image: IconCompat, imageMode: Int) Adds an image to the cell. |
open GridRowBuilder.CellBuilder |
addImage(@Nullable image: IconCompat?, imageMode: Int, isLoading: Boolean) Adds an image to the cell. |
open GridRowBuilder.CellBuilder |
addOverlayText(@NonNull text: CharSequence) Adds text to the cell. |
open GridRowBuilder.CellBuilder |
addOverlayText(@Nullable text: CharSequence?, isLoading: Boolean) Adds text to the cell. |
open GridRowBuilder.CellBuilder |
addText(@NonNull text: CharSequence) Adds text to the cell. |
open GridRowBuilder.CellBuilder |
addText(@Nullable text: CharSequence?, isLoading: Boolean) Adds text to the cell. |
open GridRowBuilder.CellBuilder |
addTitleText(@NonNull text: CharSequence) Adds text to the cell. |
open GridRowBuilder.CellBuilder |
addTitleText(@Nullable text: CharSequence?, isLoading: Boolean) Adds text to the cell. |
open GridRowBuilder.CellBuilder |
setContentDescription(@NonNull description: CharSequence) Sets the content description for this cell. |
open GridRowBuilder.CellBuilder |
setContentIntent(@NonNull intent: PendingIntent) Sets the action to be invoked if the user taps on this cell in the row. |
open GridRowBuilder.CellBuilder |
setContentIntent(@NonNull callback: RemoteCallback) Sets the action to be invoked if the user taps on this cell in the row. |
open GridRowBuilder.CellBuilder |
setSliceAction(@NonNull action: SliceAction) Sets the SliceAction for the cell. |
Public constructors
<init>
CellBuilder()
Create a builder which will construct a slice displayed as a cell in a grid.
Public methods
addImage
@NonNull open fun addImage(
@NonNull 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. |
addImage
@NonNull open fun addImage(
@Nullable 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