GridRowBuilder
@RequiresApi(value = 19)
public class GridRowBuilder
GridRowBuilderDsl |
Helper class annotated with @SliceMarker, which is annotated with @DslMarker. |
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:
ICON_IMAGE- icon images are expected to be tintable and are shown at a standard icon size.SMALL_IMAGE- small images are not tinted and are shown at a small size.LARGE_IMAGE- large images are not tinted and are shown as large as they can be, in aCENTER_CROP
If more cells are added to the grid row than can be displayed, the cells will be cut off. Using setSeeMoreAction 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.
| See also | |
|---|---|
addGridRow |
Summary
Nested types |
|---|
public class GridRowBuilder.CellBuilderBuilder to construct a cell. |
Public constructors |
|---|
|
Create a builder which will construct a slice displayed in a grid format. |
Public methods |
|
|---|---|
@NonNull GridRowBuilder |
addCell(@NonNull GridRowBuilder.CellBuilder builder)Add a cell to the grid builder. |
@NonNull GridRowBuilder |
setContentDescription(@NonNull CharSequence description)Sets the content description for the entire grid row. |
@NonNull GridRowBuilder |
setLayoutDirection(int layoutDirection)Sets the desired layout direction for the content in this row. |
@NonNull GridRowBuilder |
setPrimaryAction(@NonNull SliceAction action)Sets the intent to send when the whole grid row is clicked. |
@NonNull GridRowBuilder |
setSeeMoreAction(@NonNull RemoteCallback callback)If all content in a slice cannot be shown, a "see more" affordance may be displayed where the content is cut off. |
@NonNull GridRowBuilder |
setSeeMoreAction(@NonNull PendingIntent intent)If all content in a slice cannot be shown, a "see more" affordance may be displayed where the content is cut off. |
@NonNull GridRowBuilder |
setSeeMoreCell(@NonNull GridRowBuilder.CellBuilder builder)If all content in a slice cannot be shown, the cell added here may be displayed where the content is cut off. |
Public constructors
GridRowBuilder
public GridRowBuilder()
Create a builder which will construct a slice displayed in a grid format.
Public methods
addCell
public @NonNull GridRowBuilder addCell(@NonNull GridRowBuilder.CellBuilder builder)
Add a cell to the grid builder.
setContentDescription
public @NonNull GridRowBuilder setContentDescription(@NonNull CharSequence description)
Sets the content description for the entire grid row.
setLayoutDirection
public @NonNull GridRowBuilder setLayoutDirection(int layoutDirection)
Sets the desired layout direction for the content in this row.
| Parameters | |
|---|---|
int layoutDirection |
the layout direction to set. |
setPrimaryAction
public @NonNull GridRowBuilder setPrimaryAction(@NonNull SliceAction action)
Sets the intent to send when the whole grid row is clicked.
If all the cells in the grid have specified a setPrimaryAction 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 MODE_SHORTCUT.
setSeeMoreAction
public @NonNull GridRowBuilder setSeeMoreAction(@NonNull RemoteCallback callback)
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
public @NonNull GridRowBuilder setSeeMoreAction(@NonNull 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.
setSeeMoreCell
public @NonNull GridRowBuilder setSeeMoreCell(@NonNull GridRowBuilder.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 setSeeMoreAction otherwise. If you do choose to specify a custom cell, the cell should have setContentIntent 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.