# ListTemplate

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/ListTemplate.java+class:androidx.car.app.model.ListTemplate) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

*** ** * ** ***


```
@CarProtocol
public final class ListTemplate implements Template
```

<br />

*** ** * ** ***

A template representing a list of items.

#### 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/ListTemplate.Builder#setLoading(boolean)`}, or
- The template title has not changed, and the `https://developer.android.com/reference/androidx/car/app/model/ItemList` structure between the templates have not changed. This means that if the previous template has multiple `https://developer.android.com/reference/androidx/car/app/model/ItemList` sections, the new template must have the same number of sections with the same headers. Further, the number of rows and the title (not counting spans) of each row must not have changed.
- For rows that contain a `https://developer.android.com/reference/androidx/car/app/model/Toggle`, updates to the title are also allowed if the toggle state has changed between the previous and new templates.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/car/app/model/ListTemplate.Builder` A builder of `https://developer.android.com/reference/androidx/car/app/model/ListTemplate`. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/ListTemplate#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/Nullable.html https://developer.android.com/reference/androidx/car/app/model/ActionStrip` | `[getActionStrip](https://developer.android.com/reference/androidx/car/app/model/ListTemplate#getActionStrip())()` **This method is deprecated.** use `https://developer.android.com/reference/androidx/car/app/model/Header#getEndHeaderActions()` instead. <br /> |
| `@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/Action>` | `@https://developer.android.com/reference/androidx/car/app/annotations/RequiresCarApi(value = 6) https://developer.android.com/reference/androidx/car/app/model/ListTemplate#getActions()()` Returns the list of additional actions. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/Header` | `https://developer.android.com/reference/androidx/car/app/model/ListTemplate#getHeader()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/Header` to display in this template. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/Action` | `[getHeaderAction](https://developer.android.com/reference/androidx/car/app/model/ListTemplate#getHeaderAction())()` **This method is deprecated.** use `https://developer.android.com/reference/androidx/car/app/model/Header#getStartHeaderAction()` instead. <br /> |
| `@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/SectionedItemList>` | `https://developer.android.com/reference/androidx/car/app/model/ListTemplate#getSectionedLists()()` Returns the list of `https://developer.android.com/reference/androidx/car/app/model/SectionedItemList` instances to be displayed in the template. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/ItemList` | `https://developer.android.com/reference/androidx/car/app/model/ListTemplate#getSingleList()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/ItemList` instance containing the list of items to display or ` null` if one hasn't been set. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarText` | `[getTitle](https://developer.android.com/reference/androidx/car/app/model/ListTemplate#getTitle())()` **This method is deprecated.** use `https://developer.android.com/reference/androidx/car/app/model/Header#getTitle()` instead. <br /> |
| `int` | `https://developer.android.com/reference/androidx/car/app/model/ListTemplate#hashCode()()` |
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/ListTemplate#isLoading()()` Returns whether the template is loading. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/ListTemplate.Builder` | `https://developer.android.com/reference/androidx/car/app/model/ListTemplate#toBuilder()()` Creates and returns a new `https://developer.android.com/reference/androidx/car/app/model/ListTemplate.Builder` initialized with this `https://developer.android.com/reference/androidx/car/app/model/ListTemplate`'s data. |
| `@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/ListTemplate#toString()()` |

## Public methods

### equals

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

### getActionStrip

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

```
public @Nullable ActionStrip [getActionStrip](https://developer.android.com/reference/androidx/car/app/model/ListTemplate#getActionStrip())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> use `https://developer.android.com/reference/androidx/car/app/model/Header#getEndHeaderActions()` instead.

Returns the `https://developer.android.com/reference/androidx/car/app/model/ActionStrip` for this template or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/ListTemplate.Builder#setActionStrip(androidx.car.app.model.ActionStrip)` |   |

### getActions

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

```
@RequiresCarApi(value = 6)
public @NonNull List<Action> getActions()
```

Returns the list of additional actions.

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

### getHeader

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

```
public @Nullable Header getHeader()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/Header` to display in this template.

This method was introduced in API 7, but is backwards compatible even if the client is using API 6 or below.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/ListTemplate.Builder#setHeader(androidx.car.app.model.Header)` |   |

### getHeaderAction

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

```
public @Nullable Action [getHeaderAction](https://developer.android.com/reference/androidx/car/app/model/ListTemplate#getHeaderAction())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> use `https://developer.android.com/reference/androidx/car/app/model/Header#getStartHeaderAction()` instead.

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/ListTemplate.Builder#setHeaderAction(androidx.car.app.model.Action)` |   |

### getSectionedLists

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

```
public @NonNull List<SectionedItemList> getSectionedLists()
```

Returns the list of `https://developer.android.com/reference/androidx/car/app/model/SectionedItemList` instances to be displayed in the template.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/ListTemplate.Builder#addSectionedList(androidx.car.app.model.SectionedItemList)` |   |

### getSingleList

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

```
public @Nullable ItemList getSingleList()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/ItemList` instance containing the list of items to display or `
null` if one hasn't been set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/ListTemplate.Builder#setSingleList(androidx.car.app.model.ItemList)` |   |

### getTitle

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

```
public @Nullable CarText [getTitle](https://developer.android.com/reference/androidx/car/app/model/ListTemplate#getTitle())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> use `https://developer.android.com/reference/androidx/car/app/model/Header#getTitle()` instead.

Returns the title of the template or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/ListTemplate.Builder#setTitle(java.lang.CharSequence)` |   |

### hashCode

```
public int hashCode()
```

### isLoading

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

```
public boolean isLoading()
```

Returns whether the template is loading.

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

### toBuilder

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

```
public @NonNull ListTemplate.Builder toBuilder()
```

Creates and returns a new `https://developer.android.com/reference/androidx/car/app/model/ListTemplate.Builder` initialized with this `https://developer.android.com/reference/androidx/car/app/model/ListTemplate`'s data.

### toString

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