public final class

TabTemplate.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.car.app.model.TabTemplate.Builder

Overview

A builder of TabTemplate.

Summary

Constructors
publicBuilder(TabTemplate.TabCallback callback)

Creates a TabTemplate.Builder instance using the given TabTemplate.TabCallback.

publicBuilder(TabTemplate tabTemplate)

Creates a new TabTemplate.Builder, populated from the input TabTemplate

Methods
public TabTemplate.BuilderaddTab(Tab tab)

Adds an Tab to display in the template.

public TabTemplatebuild()

Constructs the template defined by this builder.

public TabTemplate.BuildersetActiveTabContentId(java.lang.String contentId)

Stores the given contentId as the "active tab" to show on the screen.

public TabTemplate.BuildersetHeaderAction(Action headerAction)

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

public TabTemplate.BuildersetLoading(boolean isLoading)

Sets whether the template is in a loading state.

public TabTemplate.BuildersetTabContents(TabContents tabContents)

Sets the TabContents to show in the template.

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

Constructors

public Builder(TabTemplate.TabCallback callback)

Creates a TabTemplate.Builder instance using the given TabTemplate.TabCallback.

Note that the callback relates to UI events and will be executed on the main thread using .

Parameters:

callback: the callback to be invoked when the user selects a new tab in the header

public Builder(TabTemplate tabTemplate)

Creates a new TabTemplate.Builder, populated from the input TabTemplate

Methods

public TabTemplate.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 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 template.

public TabTemplate.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 Action.APP_ICON as a header Action.

public TabTemplate.Builder setTabContents(TabContents tabContents)

Sets the TabContents to show in the template. Note that only certain templates may be used as content. See TabContents.Builder.Builder(Template) for more details.

public TabTemplate.Builder setActiveTabContentId(java.lang.String contentId)

Stores the given contentId as the "active tab" to show on the screen. The given ID must match a tab that was added by TabTemplate.Builder.addTab(Tab).

public TabTemplate.Builder addTab(Tab tab)

Adds an Tab to display in the template.

public TabTemplate build()

Constructs the template defined by this builder.

Requirements

The number of Tabs provided in the template should be between 2 and 4, with only one tab marked as active.

A header Action of type TYPE_APP_ICON is required.