belongs to Maven artifact androidx.slice:slice-builders:1.0.0-alpha1

GridRowBuilder.CellBuilder

public static final class GridRowBuilder.CellBuilder
extends TemplateSliceBuilder

java.lang.Object
   ↳ androidx.slice.builders.TemplateSliceBuilder
     ↳ 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:

Summary

Public constructors

GridRowBuilder.CellBuilder(GridRowBuilder parent)

Create a builder which will construct a slice displayed as a cell in a grid.

GridRowBuilder.CellBuilder(GridRowBuilder parent, Uri uri)

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 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(PendingIntent intent)

Sets the action to be invoked if the user taps on this cell in the row.

Inherited methods

Public constructors

GridRowBuilder.CellBuilder

GridRowBuilder.CellBuilder (GridRowBuilder parent)

Create a builder which will construct a slice displayed as a cell in a grid.

Parameters
parent GridRowBuilder: The builder constructing the parent slice.

GridRowBuilder.CellBuilder

GridRowBuilder.CellBuilder (GridRowBuilder parent, 
                Uri uri)

Create a builder which will construct a slice displayed as a cell in a grid.

Parameters
parent GridRowBuilder

uri Uri: Uri to tag for this slice.

Public methods

addImage

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

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

addText

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

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

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

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

GridRowBuilder.CellBuilder setContentDescription (CharSequence description)

Sets the content description for this cell.

Parameters
description CharSequence

Returns
GridRowBuilder.CellBuilder

setContentIntent

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