lightbulb_outline Help shape the future of the Google Play Console, Android Studio, and Firebase. Start survey

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

GridBuilder

public class GridBuilder
extends TemplateSliceBuilder

java.lang.Object
   ↳ androidx.slice.builders.TemplateSliceBuilder
     ↳ androidx.slice.builders.GridBuilder


This class is deprecated.
TO BE REMOVED; please use GridRowBuilder instead.

Builder to construct a row of slice content in a grid format.

A grid row is composed of cells, each cell can have a combination of text and images. For more details see GridBuilder.CellBuilder.

Summary

Nested classes

class GridBuilder.CellBuilder

This class is deprecated. TO BE REMOVED; please use GridRowBuilder.CellBuilder instead.  

Constants

int ICON_IMAGE

This constant is deprecated. use ListBuilder.ICON_IMAGE

int LARGE_IMAGE

This constant is deprecated. use ListBuilder.LARGE_IMAGE

int SMALL_IMAGE

This constant is deprecated. use ListBuilder.SMALL_IMAGE

Public constructors

GridBuilder(ListBuilder parent)

Create a builder which will construct a slice displayed in a grid format.

Public methods

GridBuilder addCell(Consumer<GridBuilder.CellBuilder> c)

Add a cell to the grid builder.

GridBuilder addCell(GridBuilder.CellBuilder builder)

Add a cell to the grid builder.

GridBuilder addSeeMoreAction(PendingIntent intent)

If all content in a slice cannot be shown, a "see more" affordance may be displayed where the content is cut off.

GridBuilder addSeeMoreCell(GridBuilder.CellBuilder builder)

If all content in a slice cannot be shown, the cell added here may be displayed where the content is cut off.

GridBuilder addSeeMoreCell(Consumer<GridBuilder.CellBuilder> c)

If all content in a slice cannot be shown, the cell added here may be displayed where the content is cut off.

GridBuilder setContentDescription(CharSequence description)

Sets the content description for the entire grid row.

GridBuilder setPrimaryAction(SliceAction action)

Sets the intent to send when the slice is activated.

Inherited methods

Constants

ICON_IMAGE

public static final int ICON_IMAGE

This constant is deprecated.
use ListBuilder.ICON_IMAGE

Indicates that an image should be presented as an icon and it can be tinted.

Constant Value: 0 (0x00000000)

LARGE_IMAGE

public static final int LARGE_IMAGE

This constant is deprecated.
use ListBuilder.LARGE_IMAGE

Indicates that an image presented in a larger size and it shouldn't be tinted.

Constant Value: 2 (0x00000002)

SMALL_IMAGE

public static final int SMALL_IMAGE

This constant is deprecated.
use ListBuilder.SMALL_IMAGE

Indicates that an image should be presented in a smaller size and it shouldn't be tinted.

Constant Value: 1 (0x00000001)

Public constructors

GridBuilder

public GridBuilder (ListBuilder parent)

Create a builder which will construct a slice displayed in a grid format.

Parameters
parent ListBuilder: The builder constructing the parent slice.

Public methods

addCell

public GridBuilder addCell (Consumer<GridBuilder.CellBuilder> c)

Add a cell to the grid builder.

Parameters
c Consumer

Returns
GridBuilder

addCell

public GridBuilder addCell (GridBuilder.CellBuilder builder)

Add a cell to the grid builder.

Parameters
builder GridBuilder.CellBuilder

Returns
GridBuilder

addSeeMoreAction

public GridBuilder addSeeMoreAction (PendingIntent intent)

If all content in a slice cannot be shown, a "see more" affordance may be displayed where the content is cut off. The action added here should take the user to an activity to see all of the content, and will be invoked when the "see more" affordance is tapped.

Only one see more affordance can be added, this throws IllegalStateException if a row or action has been previously added.

Parameters
intent PendingIntent

Returns
GridBuilder

addSeeMoreCell

public GridBuilder addSeeMoreCell (GridBuilder.CellBuilder builder)

If all content in a slice cannot be shown, the cell added here may be displayed where the content is cut off.

This method should only be used if you want to display a custom cell to indicate more content, consider using addSeeMoreAction(PendingIntent) otherwise. If you do choose to specify a custom cell, the cell should have GridBuilder.CellBuilder.setContentIntent(PendingIntent) specified to take the user to an activity to see all of the content.

Only one see more affordance can be added, this throws IllegalStateException if a row or action has been previously added.

Parameters
builder GridBuilder.CellBuilder

Returns
GridBuilder

addSeeMoreCell

public GridBuilder addSeeMoreCell (Consumer<GridBuilder.CellBuilder> c)

If all content in a slice cannot be shown, the cell added here may be displayed where the content is cut off.

This method should only be used if you want to display a custom cell to indicate more content, consider using addSeeMoreAction(PendingIntent) otherwise. If you do choose to specify a custom cell, the cell should have GridBuilder.CellBuilder.setContentIntent(PendingIntent) specified to take the user to an activity to see all of the content.

Only one see more affordance can be added, this throws IllegalStateException if a row or action has been previously added.

Parameters
c Consumer

Returns
GridBuilder

setContentDescription

public GridBuilder setContentDescription (CharSequence description)

Sets the content description for the entire grid row.

Parameters
description CharSequence

Returns
GridBuilder

setPrimaryAction

public GridBuilder setPrimaryAction (SliceAction action)

Sets the intent to send when the slice is activated.

Parameters
action SliceAction

Returns
GridBuilder