The Android Developer Challenge is back! Submit your idea before December 2.

GridRowBuilder

open class GridRowBuilder
kotlin.Any
   ↳ androidx.slice.builders.GridRowBuilder

Builder to construct a grid row which may be added as a row to ListBuilder.

A grid row supports cells of vertically laid out content in a single row. Each cell can contain a combination of text and images and is constructed using a CellBuilder.

A grid supports a couple of image types:

If more cells are added to the grid row than can be displayed, the cells will be cut off. Using setSeeMoreAction(PendingIntent) you can specify an action to take the user to see the rest of the content, this will take up space as a cell item in a row if added.

Summary

Nested classes

open

Builder to construct a cell.

Public constructors

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

Public methods

open GridRowBuilder

Add a cell to the grid builder.

open GridRowBuilder
setContentDescription(@NonNull description: CharSequence)

Sets the content description for the entire grid row.

open GridRowBuilder
setLayoutDirection(layoutDirection: Int)

Sets the desired layout direction for the content in this row.

open GridRowBuilder
setPrimaryAction(@NonNull action: SliceAction)

Sets the intent to send when the whole grid row is clicked.

open GridRowBuilder
setSeeMoreAction(@NonNull intent: PendingIntent)

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

open GridRowBuilder
setSeeMoreAction(@NonNull callback: RemoteCallback)

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

open GridRowBuilder

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

Public constructors

<init>

GridRowBuilder()

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

Public methods

addCell

@NonNull open fun addCell(@NonNull builder: GridRowBuilder.CellBuilder): GridRowBuilder

Add a cell to the grid builder.

setContentDescription

@NonNull open fun setContentDescription(@NonNull description: CharSequence): GridRowBuilder

Sets the content description for the entire grid row.

setLayoutDirection

@NonNull open fun setLayoutDirection(layoutDirection: Int): GridRowBuilder

Sets the desired layout direction for the content in this row.

Parameters
layoutDirection Int: the layout direction to set.

setPrimaryAction

@NonNull open fun setPrimaryAction(@NonNull action: SliceAction): GridRowBuilder

Sets the intent to send when the whole grid row is clicked.

If all the cells in the grid have specified a CellBuilder#setPrimaryAction(SliceAction) then the action set here on the GridRowBuilder may not ever be invoked.

If this grid row is the first row in ListBuilder, the action set here will be used to represent the slice when presented in androidx.slice.widget.SliceView#MODE_SHORTCUT.

setSeeMoreAction

@NonNull open fun setSeeMoreAction(@NonNull intent: PendingIntent): GridRowBuilder

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.

setSeeMoreAction

@NonNull open fun setSeeMoreAction(@NonNull callback: RemoteCallback): GridRowBuilder

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.

setSeeMoreCell

@NonNull open fun setSeeMoreCell(@NonNull builder: GridRowBuilder.CellBuilder): GridRowBuilder

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 setSeeMoreAction(PendingIntent) otherwise. If you do choose to specify a custom cell, the cell should have 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.