# TabTemplate

Artifact: [androidx.car.app:app](https://developer.android.com/jetpack/androidx/releases/car-app) [View Source](https://cs.android.com/search?q=file:androidx/car/app/model/TabTemplate.java+class:androidx.car.app.model.TabTemplate) Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

*** ** * ** ***


```
@CarProtocol
@RequiresCarApi(value = 6)
public class TabTemplate implements Template
```

<br />

*** ** * ** ***

A template representing a list of tabs and contents for the active tab.

#### Template Restrictions

In regards to template refreshes, as described in `https://developer.android.com/reference/androidx/car/app/Screen#onGetTemplate()`, this template is considered a refresh of a previous one if:

- The previous template is in a loading state (see `https://developer.android.com/reference/androidx/car/app/model/TabTemplate.Builder#setLoading(boolean)`} , or
- The `https://developer.android.com/reference/androidx/car/app/model/Tab`s structure between the templates has not changed and if the new template has the same active tab then the contents of that tab hasn't changed. This means that if the previous template has multiple `https://developer.android.com/reference/androidx/car/app/model/Tab`s, the new template must have the same number of tabs with the same title and icon.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/car/app/model/TabTemplate.Builder` A builder of `https://developer.android.com/reference/androidx/car/app/model/TabTemplate`. |
| `public interface https://developer.android.com/reference/androidx/car/app/model/TabTemplate.TabCallback` A listener for tab selection. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/TabTemplate#equals(java.lang.Object)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html other)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/car/app/model/TabTemplate#getActiveTabContentId()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/Tab#getContentId()` for the active tab. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/Action` | `@https://developer.android.com/reference/androidx/car/app/annotations/RequiresCarApi(value = 9) @https://developer.android.com/reference/androidx/car/app/annotations/ExperimentalCarApi https://developer.android.com/reference/androidx/car/app/model/TabTemplate#getEndAction()()` Returns the end action displayed in the tab bar, or `null` if none has been set. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/Action` | `https://developer.android.com/reference/androidx/car/app/model/TabTemplate#getHeaderAction()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/Action` that is set to be displayed in the header of the template, or `null` if not set. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/TabStyle` | `@https://developer.android.com/reference/androidx/car/app/annotations/RequiresCarApi(value = 9) @https://developer.android.com/reference/androidx/car/app/annotations/ExperimentalCarApi https://developer.android.com/reference/androidx/car/app/model/TabTemplate#getStyle()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/TabStyle` for tabs in the template, or `null` if not set. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/TabCallbackDelegate` | `https://developer.android.com/reference/androidx/car/app/model/TabTemplate#getTabCallbackDelegate()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/TabCallbackDelegate` for tab related callbacks. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/TabContents` | `https://developer.android.com/reference/androidx/car/app/model/TabTemplate#getTabContents()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/TabContents` for the currently active tab. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/car/app/model/Tab>` | `https://developer.android.com/reference/androidx/car/app/model/TabTemplate#getTabs()()` Returns the list of `https://developer.android.com/reference/androidx/car/app/model/Tab`s in the template. |
| `int` | `https://developer.android.com/reference/androidx/car/app/model/TabTemplate#hashCode()()` |
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/TabTemplate#isLoading()()` Returns whether the template is loading. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/car/app/model/TabTemplate#toString()()` |

## Public methods

### equals

```
public boolean equals(@Nullable Object other)
```

### getActiveTabContentId

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.4.0)

```
public @NonNull String getActiveTabContentId()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/Tab#getContentId()` for the active tab.

### getEndAction

Added in [1.9.0-alpha03](https://developer.android.com/jetpack/androidx/releases/car-app#1.9.0-alpha03)

```
@RequiresCarApi(value = 9)
@ExperimentalCarApi
public @Nullable Action getEndAction()
```

Returns the end action displayed in the tab bar, or `null` if none has been set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/TabTemplate.Builder#setEndAction(androidx.car.app.model.Action)` |   |

### getHeaderAction

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

```
public @NonNull Action getHeaderAction()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/Action` that is set to be displayed in the header of the template, or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/TabTemplate.Builder#setHeaderAction(androidx.car.app.model.Action)` |   |

### getStyle

Added in [1.9.0-alpha03](https://developer.android.com/jetpack/androidx/releases/car-app#1.9.0-alpha03)

```
@RequiresCarApi(value = 9)
@ExperimentalCarApi
public @Nullable TabStyle getStyle()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/TabStyle` for tabs in the template, or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/TabTemplate.Builder#setStyle(androidx.car.app.model.TabStyle)` |   |

### getTabCallbackDelegate

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

```
public @NonNull TabCallbackDelegate getTabCallbackDelegate()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/TabCallbackDelegate` for tab related callbacks.

### getTabContents

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

```
public @NonNull TabContents getTabContents()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/TabContents` for the currently active tab.

### getTabs

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

```
public @NonNull List<Tab> getTabs()
```

Returns the list of `https://developer.android.com/reference/androidx/car/app/model/Tab`s in the template.

### hashCode

```
public int hashCode()
```

### isLoading

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.3.0)

```
public boolean isLoading()
```

Returns whether the template is loading.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/TabTemplate.Builder#setLoading(boolean)` |   |

### toString

```
public @NonNull String toString()
```