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

RowBuilder

open class RowBuilder
kotlin.Any
   ↳ 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 can be a timestamp, image, or a SliceAction. It appears with at the start of the row. There can only be one title item added to a row.
  • 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 or first row of the slice, then the action set here will be used to represent the slice shown in androidx.slice.widget.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

Builder to construct a row.

<init>(uri: Uri!)

Builder to construct a normal row.

Public methods

open ListBuilder.RowBuilder
addEndItem(timeStamp: Long)

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

open ListBuilder.RowBuilder
addEndItem(@NonNull icon: IconCompat, imageMode: Int)

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

open ListBuilder.RowBuilder
addEndItem(@Nullable icon: IconCompat?, imageMode: Int, isLoading: Boolean)

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

open ListBuilder.RowBuilder
addEndItem(@NonNull action: SliceAction)

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

open ListBuilder.RowBuilder
addEndItem(@NonNull action: SliceAction, isLoading: Boolean)

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

open ListBuilder.RowBuilder
setContentDescription(@NonNull description: CharSequence)

Sets the content description for the row.

open ListBuilder.RowBuilder
setLayoutDirection(layoutDirection: Int)

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

open ListBuilder.RowBuilder
setPrimaryAction(@NonNull action: SliceAction)

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

open ListBuilder.RowBuilder
setSubtitle(@NonNull subtitle: CharSequence)

Sets the subtitle for the row builder.

open ListBuilder.RowBuilder
setSubtitle(@Nullable subtitle: CharSequence?, isLoading: Boolean)

Sets the subtitle for the row builder.

open ListBuilder.RowBuilder
setTitle(@NonNull title: CharSequence)

Sets the title for the row builder.

open ListBuilder.RowBuilder
setTitle(@Nullable title: CharSequence?, isLoading: Boolean)

Sets the title for the row builder.

open ListBuilder.RowBuilder
setTitleItem(timeStamp: Long)

Sets the title item to be the provided timestamp.

open ListBuilder.RowBuilder!
setTitleItem(@NonNull icon: IconCompat, imageMode: Int)

Sets the title item to be the provided icon.

open ListBuilder.RowBuilder
setTitleItem(@Nullable icon: IconCompat?, imageMode: Int, isLoading: Boolean)

Sets the title item to be the provided icon.

open ListBuilder.RowBuilder
setTitleItem(@NonNull action: SliceAction)

Sets the title item to be a tappable icon.

open ListBuilder.RowBuilder
setTitleItem(@NonNull action: SliceAction, isLoading: Boolean)

Sets the title item to be a tappable icon.

Public constructors

<init>

RowBuilder()

Builder to construct a row.

<init>

RowBuilder(uri: Uri!)

Builder to construct a normal row.

Parameters
uri Uri!: Uri to tag for this slice.

Public methods

addEndItem

@NonNull open fun addEndItem(timeStamp: Long): ListBuilder.RowBuilder

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.

addEndItem

@NonNull open fun addEndItem(@NonNull icon: IconCompat, imageMode: Int): ListBuilder.RowBuilder

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

Parameters
icon IconCompat: the image to display.
imageMode IconCompat: the mode that image should be displayed in.

addEndItem

@NonNull open fun addEndItem(@Nullable icon: IconCompat?, imageMode: Int, isLoading: Boolean): ListBuilder.RowBuilder

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 IconCompat?: the mode that image should be displayed in.
isLoading IconCompat?: whether this content is being loaded in the background.

addEndItem

@NonNull open fun addEndItem(@NonNull action: SliceAction): ListBuilder.RowBuilder

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.

addEndItem

@NonNull open fun addEndItem(@NonNull action: SliceAction, isLoading: Boolean): ListBuilder.RowBuilder

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
isLoading SliceAction: indicates whether the app is doing work to load the added content in the background or not.

setContentDescription

@NonNull open fun setContentDescription(@NonNull description: CharSequence): ListBuilder.RowBuilder

Sets the content description for the row.

setLayoutDirection

@NonNull open fun setLayoutDirection(layoutDirection: Int): ListBuilder.RowBuilder

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): ListBuilder.RowBuilder

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 androidx.slice.widget.SliceView#MODE_SHORTCUT representation of the slice.

setSubtitle

@NonNull open fun setSubtitle(@NonNull subtitle: CharSequence): ListBuilder.RowBuilder

Sets the subtitle for the row builder. A subtitle should fit on a single line and is ellipsized if too long.

setSubtitle

@NonNull open fun setSubtitle(@Nullable subtitle: CharSequence?, isLoading: Boolean): ListBuilder.RowBuilder

Sets the subtitle for the row builder. A subtitle should fit on a single line and is ellipsized if too long.

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

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

setTitle

@NonNull open fun setTitle(@NonNull title: CharSequence): ListBuilder.RowBuilder

Sets the title for the row builder. A title should fit on a single line and is ellipsized if too long.

setTitle

@NonNull open fun setTitle(@Nullable title: CharSequence?, isLoading: Boolean): ListBuilder.RowBuilder

Sets the title for the row builder. A title should fit on a single line and is ellipsized if too long.

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

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

setTitleItem

@NonNull open fun setTitleItem(timeStamp: Long): ListBuilder.RowBuilder

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.

setTitleItem

open fun setTitleItem(@NonNull icon: IconCompat, imageMode: Int): ListBuilder.RowBuilder!

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 IconCompat: the mode that image should be displayed in.

setTitleItem

@NonNull open fun setTitleItem(@Nullable icon: IconCompat?, imageMode: Int, isLoading: Boolean): ListBuilder.RowBuilder

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 IconCompat?: the mode that image should be displayed in.
isLoading IconCompat?: whether this content is being loaded in the background.

setTitleItem

@NonNull open fun setTitleItem(@NonNull action: SliceAction): ListBuilder.RowBuilder

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.

setTitleItem

@NonNull open fun setTitleItem(@NonNull action: SliceAction, isLoading: Boolean): ListBuilder.RowBuilder

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
isLoading SliceAction: indicates whether the app is doing work to load the added content in the background or not.