public class

GridRowBuilder.CellBuilder

extends java.lang.Object

 java.lang.Object

↳androidx.slice.builders.GridRowBuilder.CellBuilder

Overview

Builder to construct a cell. A cell can be added as an item to GridRowBuilder via GridRowBuilder.addCell(GridRowBuilder.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

Fields
public static final intTYPE_IMAGE

public static final intTYPE_OVERLAY

public static final intTYPE_TEXT

public static final intTYPE_TITLE

Constructors
publicCellBuilder()

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

Methods
public GridRowBuilder.CellBuilderaddImage(IconCompat image, int imageMode)

Adds an image to the cell.

public GridRowBuilder.CellBuilderaddImage(IconCompat image, int imageMode, boolean isLoading)

Adds an image to the cell.

public GridRowBuilder.CellBuilderaddOverlayText(java.lang.CharSequence text)

Adds text to the cell.

public GridRowBuilder.CellBuilderaddOverlayText(java.lang.CharSequence text, boolean isLoading)

Adds text to the cell.

public GridRowBuilder.CellBuilderaddText(java.lang.CharSequence text)

Adds text to the cell.

public GridRowBuilder.CellBuilderaddText(java.lang.CharSequence text, boolean isLoading)

Adds text to the cell.

public GridRowBuilder.CellBuilderaddTitleText(java.lang.CharSequence text)

Adds text to the cell.

public GridRowBuilder.CellBuilderaddTitleText(java.lang.CharSequence text, boolean isLoading)

Adds text to the cell.

public java.lang.CharSequencegetCellDescription()

public PendingIntentgetContentIntent()

public java.util.List<java.lang.Boolean>getLoadings()

public java.util.List<java.lang.Object>getObjects()

public SliceActiongetSliceAction()

public java.lang.CharSequencegetSubtitle()

public java.lang.CharSequencegetTitle()

public java.util.List<java.lang.Integer>getTypes()

public GridRowBuilder.CellBuildersetContentDescription(java.lang.CharSequence description)

Sets the content description for this cell.

public GridRowBuilder.CellBuildersetContentIntent(PendingIntent intent)

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

public GridRowBuilder.CellBuildersetSliceAction(SliceAction action)

Sets the SliceAction for the cell.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Fields

public static final int TYPE_TEXT

public static final int TYPE_TITLE

public static final int TYPE_IMAGE

public static final int TYPE_OVERLAY

Constructors

public CellBuilder()

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

Methods

public GridRowBuilder.CellBuilder addText(java.lang.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.

public GridRowBuilder.CellBuilder addText(java.lang.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:

isLoading: indicates whether the app is doing work to load the added content in the background or not.

public GridRowBuilder.CellBuilder addTitleText(java.lang.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.

public GridRowBuilder.CellBuilder addTitleText(java.lang.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:

isLoading: indicates whether the app is doing work to load the added content in the background or not.

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: the image to display in the cell.
imageMode: the mode that image should be displayed in.

See also: ListBuilder.ICON_IMAGE, ListBuilder.SMALL_IMAGE, ListBuilder.LARGE_IMAGE

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: the image to display in the cell.
imageMode: the mode that image should be displayed in.
isLoading: indicates whether the app is doing work to load the added content in the background or not.

See also: ListBuilder.ICON_IMAGE, ListBuilder.SMALL_IMAGE, ListBuilder.LARGE_IMAGE

public GridRowBuilder.CellBuilder addOverlayText(java.lang.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.

public GridRowBuilder.CellBuilder addOverlayText(java.lang.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:

isLoading: indicates whether the app is doing work to load the added content in the background or not.

public GridRowBuilder.CellBuilder setContentIntent(PendingIntent intent)

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

public GridRowBuilder.CellBuilder setContentDescription(java.lang.CharSequence description)

Sets the content description for this cell.

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.

public java.util.List<java.lang.Object> getObjects()

public java.util.List<java.lang.Integer> getTypes()

public java.util.List<java.lang.Boolean> getLoadings()

public java.lang.CharSequence getCellDescription()

public PendingIntent getContentIntent()

public java.lang.CharSequence getTitle()

public java.lang.CharSequence getSubtitle()

public SliceAction getSliceAction()