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

HeaderBuilder

open class HeaderBuilder
kotlin.Any
   ↳ androidx.slice.builders.ListBuilder.HeaderBuilder

Builder to construct a header row.

A header provides some additional functionality compared to a RowBuilder. Like a row, a header has a title, subtitle, and primary action.

In addition to a row's title, subtitle, and primary action, a header also supports setting a summary description of the list contents using HeaderBuilder#setSummary(CharSequence). This summary might be used when the rest of the list content is not shown (e.g. if SliceView presenting slice is configured to androidx.slice.widget.SliceView#MODE_SMALL.

The primary action specified by HeaderBuilder#setPrimaryAction(SliceAction) will be used as the PendingIntent sent when header is clicked. This action is also used when when SliceView displays in androidx.slice.widget.SliceView#MODE_SHORTCUT.

Unlike row builder, header builder does not support end items (e.g. RowBuilder#addEndItem(SliceAction)). The header may be used to display actions set on the list via addAction(SliceAction).

Summary

Public constructors

Create builder for a header.

Public methods

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

Sets the content description for the header.

open ListBuilder.HeaderBuilder
setLayoutDirection(layoutDirection: Int)

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

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

Sets the action to send when the header is clicked.

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

Sets the subtitle for the header builder.

open ListBuilder.HeaderBuilder
setSubtitle(@NonNull subtitle: CharSequence, isLoading: Boolean)

Sets the subtitle for the header builder.

open ListBuilder.HeaderBuilder
setSummary(@NonNull summary: CharSequence)

Sets the summary for the header builder.

open ListBuilder.HeaderBuilder
setSummary(@NonNull summary: CharSequence, isLoading: Boolean)

Sets the summary for the header builder.

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

Sets the title for the header builder.

open ListBuilder.HeaderBuilder
setTitle(@NonNull title: CharSequence, isLoading: Boolean)

Sets the title for the header builder.

Public constructors

<init>

HeaderBuilder()

Create builder for a header.

Public methods

setContentDescription

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

Sets the content description for the header.

setLayoutDirection

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

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.HeaderBuilder

Sets the action to send when the header is clicked.

Additionally, the action specified here is used when the slice associated with this header is displayed in androidx.slice.widget.SliceView#MODE_SHORTCUT.

setSubtitle

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

Sets the subtitle for the header builder. The subtitle should fit on a single line.

setSubtitle

@NonNull open fun setSubtitle(@NonNull subtitle: CharSequence, isLoading: Boolean): ListBuilder.HeaderBuilder

Sets the subtitle for the header builder. The subtitle should fit on a single line.

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.

setSummary

@NonNull open fun setSummary(@NonNull summary: CharSequence): ListBuilder.HeaderBuilder

Sets the summary for the header builder. A summary is optional and should fit on a single line and is ellipsized if too long.

The summary should be a description of the contents of the list. This summary might be used when the rest of the list content is not shown (e.g. if SliceView presenting slice is configured to androidx.slice.widget.SliceView#MODE_SMALL.

setSummary

@NonNull open fun setSummary(@NonNull summary: CharSequence, isLoading: Boolean): ListBuilder.HeaderBuilder

Sets the summary for the header builder. A summary is optional and should fit on a single line and is ellipsized if too long.

The summary should be a description of the contents of the list. This summary might be used when the rest of the list content is not shown (e.g. if SliceView presenting slice is configured to androidx.slice.widget.SliceView#MODE_SMALL.

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.HeaderBuilder

Sets the title for the header builder. A title should be representative of the contents of the slice and fit on a single line.

setTitle

@NonNull open fun setTitle(@NonNull title: CharSequence, isLoading: Boolean): ListBuilder.HeaderBuilder

Sets the title for the header builder. A title should be representative of the contents of the slice and fit on a single line.

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.