public final class

ListTemplate.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.car.app.model.ListTemplate.Builder

Overview

A builder of ListTemplate.

Summary

Constructors
publicBuilder()

Returns an empty ListTemplate.Builder instance.

Methods
public ListTemplate.BuilderaddSectionedList(SectionedItemList list)

Adds an SectionedItemList to display in the template.

public ListTemplatebuild()

Constructs the template defined by this builder.

public ListTemplate.BuildersetActionStrip(ActionStrip actionStrip)

Sets the ActionStrip for this template or null to not display an ActionStrip.

public ListTemplate.BuildersetHeaderAction(Action headerAction)

Sets the Action that will be displayed in the header of the template, or null to not display an action.

public ListTemplate.BuildersetLoading(boolean isLoading)

Sets whether the template is in a loading state.

public ListTemplate.BuildersetSingleList(ItemList list)

Sets a single ItemList to show in the template.

public ListTemplate.BuildersetTitle(java.lang.CharSequence title)

Sets the title of the template.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Returns an empty ListTemplate.Builder instance.

Methods

public ListTemplate.Builder setLoading(boolean isLoading)

Sets whether the template is in a loading state.

If set to true, the UI will display a loading indicator where the list content would be otherwise. The caller is expected to call Screen.invalidate() and send the new template content to the host once the data is ready.

If set to false, the UI will display the contents of the ItemList instance(s) added via ListTemplate.Builder.setSingleList(ItemList) or ListTemplate.Builder.addSectionedList(SectionedItemList).

public ListTemplate.Builder setHeaderAction(Action headerAction)

Sets the Action that will be displayed in the header of the template, or null to not display an action.

Unless set with this method, the template will not have a header action.

Requirements

This template only supports either one of Action.APP_ICON and Action.BACK as a header Action.

public ListTemplate.Builder setTitle(java.lang.CharSequence title)

Sets the title of the template.

Unless set with this method, the template will not have a title.

Only DistanceSpans and DurationSpans are supported in the input string.

public ListTemplate.Builder setSingleList(ItemList list)

Sets a single ItemList to show in the template.

Note that this list cannot be mixed with others added via ListTemplate.Builder.addSectionedList(SectionedItemList) . If multiple lists were previously added, they will be cleared.

public ListTemplate.Builder addSectionedList(SectionedItemList list)

Adds an SectionedItemList to display in the template.

Use this method to add multiple lists to the template. Each SectionedItemList will be grouped under its header. These lists cannot be mixed with an ItemList added via ListTemplate.Builder.setSingleList(ItemList). If a single list was previously added, it will be cleared.

If the added SectionedItemList contains a ItemList.OnSelectedListener, then it cannot be added alongside other SectionedItemList(s).

public ListTemplate.Builder setActionStrip(ActionStrip actionStrip)

Sets the ActionStrip for this template or null to not display an ActionStrip.

Unless set with this method, the template will not have an action strip.

Requirements

This template allows up to 2 Actions in its ActionStrip. Of the 2 allowed Actions, one of them can contain a title as set via Action.Builder.setTitle(CharSequence). Otherwise, only Actions with icons are allowed.

public ListTemplate build()

Constructs the template defined by this builder.

Requirements

The number of items in the ItemList should be smaller or equal than the limit provided by ConstraintManager.CONTENT_LIMIT_TYPE_LIST. The host will ignore any items over that limit. Each Rows can add up to 2 lines of texts via Row.Builder.addText(CharSequence).

Either a header Action or the title must be set on the template.

See also: ConstraintManager.getContentLimit(int)