added in version 1.0.0
belongs to Maven artifact androidx.slice:slice-builders:1.0.0-beta01

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:

Summary

Public constructors

GridRowBuilder.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 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

added in version 1.0.0
public GridRowBuilder.CellBuilder ()

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

Public methods

addImage

added in version 1.0.0
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

added in version 1.0.0
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

addText

added in version 1.0.0
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

added in version 1.0.0
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

added in version 1.0.0
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

added in version 1.0.0
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

added in version 1.0.0
public GridRowBuilder.CellBuilder setContentDescription (CharSequence description)

Sets the content description for this cell.

Parameters
description CharSequence

Returns
GridRowBuilder.CellBuilder

setContentIntent

added in version 1.0.0
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