GridRowBuilder.CellBuilder
public
static
class
GridRowBuilder.CellBuilder
extends Object
java.lang.Object | |
↳ | 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 aImageView.ScaleType.CENTER_CROP
See also:
Summary
Public constructors | |
---|---|
CellBuilder()
Create a builder which will construct a slice displayed as a cell in a grid. |
Public methods | |
---|---|
GridRowBuilder.CellBuilder
|
addImage(IconCompat image, int imageMode)
Adds an image to the cell. |
GridRowBuilder.CellBuilder
|
addImage(IconCompat image, int imageMode, boolean isLoading)
Adds an image to the cell. |
GridRowBuilder.CellBuilder
|
addOverlayText(CharSequence text)
Adds text to the cell. |
GridRowBuilder.CellBuilder
|
addOverlayText(CharSequence text, boolean isLoading)
Adds text to the cell. |
GridRowBuilder.CellBuilder
|
addText(CharSequence text)
Adds text to the cell. |
GridRowBuilder.CellBuilder
|
addText(CharSequence text, boolean isLoading)
Adds text to the cell. |
GridRowBuilder.CellBuilder
|
addTitleText(CharSequence text, boolean isLoading)
Adds text to the cell. |
GridRowBuilder.CellBuilder
|
addTitleText(CharSequence text)
Adds text to the cell. |
GridRowBuilder.CellBuilder
|
setContentDescription(CharSequence description)
Sets the content description for this cell. |
GridRowBuilder.CellBuilder
|
setContentIntent(RemoteCallback callback)
Sets the action to be invoked if the user taps on this cell in the row. |
GridRowBuilder.CellBuilder
|
setContentIntent(PendingIntent intent)
Sets the action to be invoked if the user taps on this cell in the row. |
GridRowBuilder.CellBuilder
|
setSliceAction(SliceAction action)
Sets the SliceAction for the cell. |
Inherited methods | |
---|---|
Public constructors
CellBuilder
public CellBuilder ()
Create a builder which will construct a slice displayed as a cell in a grid.
Public methods
addImage
public GridRowBuilder.CellBuilder addImage (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 | |
---|---|
image |
IconCompat : the image to display in the cell. |
imageMode |
int : the mode that image should be displayed in. |
Returns | |
---|---|
GridRowBuilder.CellBuilder |
addImage
public GridRowBuilder.CellBuilder addImage (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 | |
---|---|
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. |
Returns | |
---|---|
GridRowBuilder.CellBuilder |
addOverlayText
public GridRowBuilder.CellBuilder addOverlayText (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.
Parameters | |
---|---|
text |
CharSequence |
Returns | |
---|---|
GridRowBuilder.CellBuilder |
addOverlayText
public GridRowBuilder.CellBuilder addOverlayText (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 | |
---|---|
text |
CharSequence |
isLoading |
boolean : indicates whether the app is doing work to load the added content in the
background or not.
|
Returns | |
---|---|
GridRowBuilder.CellBuilder |
addText
public GridRowBuilder.CellBuilder addText (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.
Parameters | |
---|---|
text |
CharSequence |
Returns | |
---|---|
GridRowBuilder.CellBuilder |
addText
public GridRowBuilder.CellBuilder addText (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 | |
---|---|
text |
CharSequence |
isLoading |
boolean : indicates whether the app is doing work to load the added content in the
background or not.
|
Returns | |
---|---|
GridRowBuilder.CellBuilder |
addTitleText
public GridRowBuilder.CellBuilder addTitleText (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 | |
---|---|
text |
CharSequence |
isLoading |
boolean : indicates whether the app is doing work to load the added content in the
background or not.
|
Returns | |
---|---|
GridRowBuilder.CellBuilder |
addTitleText
public GridRowBuilder.CellBuilder addTitleText (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.
Parameters | |
---|---|
text |
CharSequence |
Returns | |
---|---|
GridRowBuilder.CellBuilder |
setContentDescription
public GridRowBuilder.CellBuilder setContentDescription (CharSequence description)
Sets the content description for this cell.
Parameters | |
---|---|
description |
CharSequence |
Returns | |
---|---|
GridRowBuilder.CellBuilder |
setContentIntent
public GridRowBuilder.CellBuilder setContentIntent (RemoteCallback callback)
Sets the action to be invoked if the user taps on this cell in the row.
Parameters | |
---|---|
callback |
RemoteCallback |
Returns | |
---|---|
GridRowBuilder.CellBuilder |
setContentIntent
public GridRowBuilder.CellBuilder setContentIntent (PendingIntent intent)
Sets the action to be invoked if the user taps on this cell in the row.
Parameters | |
---|---|
intent |
PendingIntent |
Returns | |
---|---|
GridRowBuilder.CellBuilder |
setSliceAction
public GridRowBuilder.CellBuilder setSliceAction (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.
Parameters | |
---|---|
action |
SliceAction |
Returns | |
---|---|
GridRowBuilder.CellBuilder |