TabTemplate.Builder
class TabTemplate.Builder
A builder of TabTemplate.
Summary
Public constructors |
|---|
Builder(callback: TabTemplate.TabCallback)Creates a |
Builder(tabTemplate: TabTemplate)Creates a new |
Public functions |
|
|---|---|
TabTemplate.Builder |
Adds an |
TabTemplate |
build()Constructs the template defined by this builder. |
TabTemplate.Builder |
setActiveTabContentId(contentId: String)Stores the given |
TabTemplate.Builder |
@RequiresCarApi(value = 9)Sets an |
TabTemplate.Builder |
setHeaderAction(headerAction: Action)Sets the |
TabTemplate.Builder |
setLoading(isLoading: Boolean)Sets whether the template is in a loading state. |
TabTemplate.Builder |
@RequiresCarApi(value = 9)Sets the |
TabTemplate.Builder |
setTabContents(tabContents: TabContents)Sets the |
Public constructors
Builder
Builder(callback: TabTemplate.TabCallback)
Creates a TabTemplate.Builder instance using the given TabCallback.
Note that the callback relates to UI events and will be executed on the main thread using getMainLooper.
| Parameters | |
|---|---|
callback: TabTemplate.TabCallback |
the callback to be invoked when the user selects a new tab in the header |
Builder
Builder(tabTemplate: TabTemplate)
Creates a new Builder, populated from the input TabTemplate
Public functions
addTab
fun addTab(tab: Tab): TabTemplate.Builder
Adds an Tab to display in the template.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
build
fun build(): TabTemplate
Constructs the template defined by this builder.
Requirements
The number ofTabs 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.
| Throws | |
|---|---|
java.lang.IllegalStateException |
if the template is in a loading state but there are tabs added or vice versa |
java.lang.IllegalArgumentException |
if the added |
setActiveTabContentId
fun setActiveTabContentId(contentId: String): TabTemplate.Builder
Stores the given contentId as the "active tab" to show on the screen. The given ID must match a tab that was added by addTab.
setEndAction
@RequiresCarApi(value = 9)
@ExperimentalCarApi
fun setEndAction(endAction: Action?): TabTemplate.Builder
Sets an Action to be displayed at the end of the header/tab bar, or null to clear the end action.
Requirements
The end action displayed in the tab bar must have an icon and must not have a title.| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if |
setHeaderAction
fun setHeaderAction(headerAction: Action): TabTemplate.Builder
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 supportsAPP_ICON as a header Action.
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if |
java.lang.NullPointerException |
if |
setLoading
fun setLoading(isLoading: Boolean): TabTemplate.Builder
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 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.
setStyle
@RequiresCarApi(value = 9)
@ExperimentalCarApi
fun setStyle(tabStyle: TabStyle?): TabTemplate.Builder
Sets the TabStyle for all tabs in this template, or null to clear the style.
Any fields not explicitly set here or in the individual tab styling of setStyle will fall back to host defaults.
setTabContents
fun setTabContents(tabContents: TabContents): TabTemplate.Builder
Sets the TabContents to show in the template. Note that only certain templates may be used as content. See Builder for more details.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |