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

ListBuilder.RowBuilder

public static class ListBuilder.RowBuilder
extends TemplateSliceBuilder

java.lang.Object
   ↳ androidx.slice.builders.TemplateSliceBuilder
     ↳ androidx.slice.builders.ListBuilder.RowBuilder


Builder to construct a row. A row can be added as an item to ListBuilder via ListBuilder.addRow(RowBuilder).

A row supports:

  • Title item - The title item appears with at the start of the row. There can only be one title item added to a row, and it could be a timestamp, image, or a SliceAction.
  • Title - Single line of text formatted as a title, see setTitle(CharSequence).
  • Subtitle - Single line of text below the title (if one exists) and is formatted as normal text, see setSubtitle(CharSequence).
  • End item - End items appear at the end of the row. There can be multiple end items that show depending on available width. End items can be a timestamp, image, or a tappable icon.
  • Primary action - The primary action for the row, this is the action that will be sent when the row is clicked. This is set via setPrimaryAction(SliceAction). If this is the only row in a slice, the slice action set here will be used to represent the slice in when slice view is displaying in SliceView.MODE_SMALL.
There are a couple of restrictions to how content can be added to a row:
  • End items cannot contain a mixture of SliceActions and Icons.
  • There can only be one timestamp added to the row.

Summary

Public constructors

ListBuilder.RowBuilder(ListBuilder parent)

Builder to construct a row.

ListBuilder.RowBuilder(ListBuilder parent, Uri uri)

Builder to construct a row.

ListBuilder.RowBuilder(Context context, Uri uri)

Builder to construct a normal row.

Public methods

ListBuilder.RowBuilder addEndItem(Icon icon, int imageMode, boolean isLoading)

This method is deprecated. TO BE REMOVED

ListBuilder.RowBuilder addEndItem(Icon icon, int imageMode)

This method is deprecated. TO BE REMOVED

ListBuilder.RowBuilder addEndItem(IconCompat icon, int imageMode)

Adds an icon to the end items of the row builder.

ListBuilder.RowBuilder addEndItem(IconCompat icon)

This method is deprecated. use ListBuilderaddEndItem(Icon, int) instead.

ListBuilder.RowBuilder addEndItem(Icon icon, boolean isLoading)

This method is deprecated. TO BE REMOVED

ListBuilder.RowBuilder addEndItem(long timeStamp)

Adds a timestamp to the end items of the row builder.

ListBuilder.RowBuilder addEndItem(SliceAction action, boolean isLoading)

Adds an action to the end items of the row builder.

ListBuilder.RowBuilder addEndItem(SliceAction action)

Adds an action to the end items of the row builder.

ListBuilder.RowBuilder addEndItem(Icon icon)

This method is deprecated. TO BE REMOVED

ListBuilder.RowBuilder addEndItem(IconCompat icon, boolean isLoading)

This method is deprecated. use ListBuilderaddEndItem(Icon, int, boolean) instead.

ListBuilder.RowBuilder addEndItem(IconCompat icon, int imageMode, boolean isLoading)

Adds an icon to the end items of the row builder.

ListBuilder.RowBuilder setContentDescription(CharSequence description)

Sets the content description for the row.

ListBuilder.RowBuilder setLayoutDirection(int layoutDirection)

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

ListBuilder.RowBuilder setPrimaryAction(SliceAction action)

The action specified here will be sent when the whole row is clicked.

ListBuilder.RowBuilder setSubtitle(CharSequence subtitle)

Sets the subtitle for the row builder.

ListBuilder.RowBuilder setSubtitle(CharSequence subtitle, boolean isLoading)

Sets the subtitle for the row builder.

ListBuilder.RowBuilder setTitle(CharSequence title)

Sets the title for the row builder.

ListBuilder.RowBuilder setTitle(CharSequence title, boolean isLoading)

Sets the title for the row builder.

ListBuilder.RowBuilder setTitleItem(SliceAction action)

Sets the title item to be a tappable icon.

ListBuilder.RowBuilder setTitleItem(Icon icon, int imageMode, boolean isLoading)

This method is deprecated. TO BE REMOVED.

ListBuilder.RowBuilder setTitleItem(Icon icon)

This method is deprecated. TO BE REMOVED.

ListBuilder.RowBuilder setTitleItem(IconCompat icon, int imageMode)

Sets the title item to be the provided icon.

ListBuilder.RowBuilder setTitleItem(Icon icon, int imageMode)

This method is deprecated. TO BE REMOVED.

ListBuilder.RowBuilder setTitleItem(IconCompat icon)

This method is deprecated. TO BE REMOVED; use ListBuildersetTitleItem(Icon, int, boolean).

ListBuilder.RowBuilder setTitleItem(long timeStamp)

Sets the title item to be the provided timestamp.

ListBuilder.RowBuilder setTitleItem(IconCompat icon, boolean isLoading)

This method is deprecated. TO BE REMOVED; use ListBuildersetTitleItem(Icon, int, boolean).

ListBuilder.RowBuilder setTitleItem(IconCompat icon, int imageMode, boolean isLoading)

Sets the title item to be the provided icon.

ListBuilder.RowBuilder setTitleItem(Icon icon, boolean isLoading)

This method is deprecated. TO BE REMOVED.

ListBuilder.RowBuilder setTitleItem(SliceAction action, boolean isLoading)

Sets the title item to be a tappable icon.

Inherited methods

Public constructors

ListBuilder.RowBuilder

public ListBuilder.RowBuilder (ListBuilder parent)

Builder to construct a row.

Parameters
parent ListBuilder: The builder constructing the parent slice.

ListBuilder.RowBuilder

public ListBuilder.RowBuilder (ListBuilder parent, 
                Uri uri)

Builder to construct a row.

Parameters
parent ListBuilder

uri Uri: Uri to tag for this slice.

ListBuilder.RowBuilder

public ListBuilder.RowBuilder (Context context, 
                Uri uri)

Builder to construct a normal row.

Parameters
context Context

uri Uri: Uri to tag for this slice.

Public methods

addEndItem

public ListBuilder.RowBuilder addEndItem (Icon icon, 
                int imageMode, 
                boolean isLoading)

This method is deprecated.
TO BE REMOVED

Parameters
icon Icon

imageMode int

isLoading boolean

Returns
ListBuilder.RowBuilder

addEndItem

public ListBuilder.RowBuilder addEndItem (Icon icon, 
                int imageMode)

This method is deprecated.
TO BE REMOVED

Parameters
icon Icon

imageMode int

Returns
ListBuilder.RowBuilder

addEndItem

public ListBuilder.RowBuilder addEndItem (IconCompat icon, 
                int imageMode)

Adds an icon to the end items of the row builder.

Parameters
icon IconCompat: the image to display.

imageMode int: the mode that image should be displayed in.

Returns
ListBuilder.RowBuilder

addEndItem

public ListBuilder.RowBuilder addEndItem (IconCompat icon)

This method is deprecated.
use ListBuilderaddEndItem(Icon, int) instead.

Adds an icon to the end items of the row builder. A mixture of icons and actions is not permitted. If an action has already been added this will throw IllegalArgumentException.

Parameters
icon IconCompat

Returns
ListBuilder.RowBuilder

addEndItem

public ListBuilder.RowBuilder addEndItem (Icon icon, 
                boolean isLoading)

This method is deprecated.
TO BE REMOVED

Parameters
icon Icon

isLoading boolean

Returns
ListBuilder.RowBuilder

addEndItem

public ListBuilder.RowBuilder addEndItem (long timeStamp)

Adds a timestamp to the end items of the row builder. Only one timestamp can be added, if one is already added this will throw IllegalArgumentException.

Parameters
timeStamp long

Returns
ListBuilder.RowBuilder

addEndItem

public ListBuilder.RowBuilder addEndItem (SliceAction action, 
                boolean isLoading)

Adds an action to the end items of the row builder. A mixture of icons and actions is not permitted. If an icon has already been added, this will throw IllegalArgumentException.

Use this method to specify content that will appear in the template once it's been loaded.

Parameters
action SliceAction

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

Returns
ListBuilder.RowBuilder

addEndItem

public ListBuilder.RowBuilder addEndItem (SliceAction action)

Adds an action to the end items of the row builder. A mixture of icons and actions is not permitted. If an icon has already been added, this will throw IllegalArgumentException.

Parameters
action SliceAction

Returns
ListBuilder.RowBuilder

addEndItem

public ListBuilder.RowBuilder addEndItem (Icon icon)

This method is deprecated.
TO BE REMOVED

Parameters
icon Icon

Returns
ListBuilder.RowBuilder

addEndItem

public ListBuilder.RowBuilder addEndItem (IconCompat icon, 
                boolean isLoading)

This method is deprecated.
use ListBuilderaddEndItem(Icon, int, boolean) instead.

Adds an icon to be displayed at the end of the row. A mixture of icons and actions is not permitted. If an action has already been added this will throw IllegalArgumentException.

Use this method to specify content that will appear in the template once it's been loaded.

Parameters
icon IconCompat

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

Returns
ListBuilder.RowBuilder

addEndItem

public ListBuilder.RowBuilder addEndItem (IconCompat icon, 
                int imageMode, 
                boolean isLoading)

Adds an icon to the end items of the row builder.

When set to true, the parameter isLoading indicates that the app is doing work to load this content in the background, in this case the template displays a placeholder until updated.

Parameters
icon IconCompat: the image to display.

imageMode int: the mode that image should be displayed in.

isLoading boolean: whether this content is being loaded in the background.

Returns
ListBuilder.RowBuilder

setContentDescription

public ListBuilder.RowBuilder setContentDescription (CharSequence description)

Sets the content description for the row.

Parameters
description CharSequence

Returns
ListBuilder.RowBuilder

setLayoutDirection

public ListBuilder.RowBuilder setLayoutDirection (int layoutDirection)

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

Parameters
layoutDirection int: the layout direction to set.

Returns
ListBuilder.RowBuilder

setPrimaryAction

public ListBuilder.RowBuilder setPrimaryAction (SliceAction action)

The action specified here will be sent when the whole row is clicked.

If this is the first row in a ListBuilder this action will also be used to define the SliceView.MODE_SHORTCUT representation of the slice.

Parameters
action SliceAction

Returns
ListBuilder.RowBuilder

setSubtitle

public ListBuilder.RowBuilder setSubtitle (CharSequence subtitle)

Sets the subtitle for the row builder.

Parameters
subtitle CharSequence

Returns
ListBuilder.RowBuilder

setSubtitle

public ListBuilder.RowBuilder setSubtitle (CharSequence subtitle, 
                boolean isLoading)

Sets the subtitle for the row builder.

Use this method to specify content that will appear in the template once it's been loaded.

Parameters
subtitle CharSequence

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

Returns
ListBuilder.RowBuilder

setTitle

public ListBuilder.RowBuilder setTitle (CharSequence title)

Sets the title for the row builder.

Parameters
title CharSequence

Returns
ListBuilder.RowBuilder

setTitle

public ListBuilder.RowBuilder setTitle (CharSequence title, 
                boolean isLoading)

Sets the title for the row builder.

Use this method to specify content that will appear in the template once it's been loaded.

Parameters
title CharSequence

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

Returns
ListBuilder.RowBuilder

setTitleItem

public ListBuilder.RowBuilder setTitleItem (SliceAction action)

Sets the title item to be a tappable icon. There can only be one title item, this will replace any other title items that may have been set.

Parameters
action SliceAction

Returns
ListBuilder.RowBuilder

setTitleItem

public ListBuilder.RowBuilder setTitleItem (Icon icon, 
                int imageMode, 
                boolean isLoading)

This method is deprecated.
TO BE REMOVED.

Parameters
icon Icon

imageMode int

isLoading boolean

Returns
ListBuilder.RowBuilder

setTitleItem

public ListBuilder.RowBuilder setTitleItem (Icon icon)

This method is deprecated.
TO BE REMOVED.

Parameters
icon Icon

Returns
ListBuilder.RowBuilder

setTitleItem

public ListBuilder.RowBuilder setTitleItem (IconCompat icon, 
                int imageMode)

Sets the title item to be the provided icon. There can only be one title item, this will replace any other title items that may have been set.

Parameters
icon IconCompat: the image to display.

imageMode int: the mode that image should be displayed in.

Returns
ListBuilder.RowBuilder

setTitleItem

public ListBuilder.RowBuilder setTitleItem (Icon icon, 
                int imageMode)

This method is deprecated.
TO BE REMOVED.

Parameters
icon Icon

imageMode int

Returns
ListBuilder.RowBuilder

setTitleItem

public ListBuilder.RowBuilder setTitleItem (IconCompat icon)

This method is deprecated.
TO BE REMOVED; use ListBuildersetTitleItem(Icon, int, boolean).

Sets the title item to be the provided icon. There can only be one title item, this will replace any other title items that may have been set.

Parameters
icon IconCompat

Returns
ListBuilder.RowBuilder

setTitleItem

public ListBuilder.RowBuilder setTitleItem (long timeStamp)

Sets the title item to be the provided timestamp. Only one timestamp can be added, if one is already added this will throw IllegalArgumentException.

There can only be one title item, this will replace any other title items that may have been set.

Parameters
timeStamp long

Returns
ListBuilder.RowBuilder

setTitleItem

public ListBuilder.RowBuilder setTitleItem (IconCompat icon, 
                boolean isLoading)

This method is deprecated.
TO BE REMOVED; use ListBuildersetTitleItem(Icon, int, boolean).

Sets the title item to be the provided icon. There can only be one title item, this will replace any other title items that may have been set.

Use this method to specify content that will appear in the template once it's been loaded.

Parameters
icon IconCompat

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

Returns
ListBuilder.RowBuilder

setTitleItem

public ListBuilder.RowBuilder setTitleItem (IconCompat icon, 
                int imageMode, 
                boolean isLoading)

Sets the title item to be the provided icon. There can only be one title item, this will replace any other title items that may have been set.

When set to true, the parameter isLoading indicates that the app is doing work to load this content in the background, in this case the template displays a placeholder until updated.

Parameters
icon IconCompat: the image to display.

imageMode int: the mode that image should be displayed in.

isLoading boolean: whether this content is being loaded in the background.

Returns
ListBuilder.RowBuilder

setTitleItem

public ListBuilder.RowBuilder setTitleItem (Icon icon, 
                boolean isLoading)

This method is deprecated.
TO BE REMOVED.

Parameters
icon Icon

isLoading boolean

Returns
ListBuilder.RowBuilder

setTitleItem

public ListBuilder.RowBuilder setTitleItem (SliceAction action, 
                boolean isLoading)

Sets the title item to be a tappable icon. There can only be one title item, this will replace any other title items that may have been set.

Use this method to specify content that will appear in the template once it's been loaded.

Parameters
action SliceAction

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

Returns
ListBuilder.RowBuilder