# SectionedItemTemplate

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

*** ** * ** ***


```
@RequiresCarApi(value = 8)
@CarProtocol
public final class SectionedItemTemplate implements Template
```

<br />

*** ** * ** ***

A template that contains sections of items like rows, grid items, chips, etc.

## Summary

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

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate#ALPHABETICAL_INDEXING_DISABLED() = 0` Indicate that alphabetical indexing should not be available for the template which also disables any UI accelerators that the user may be shown to help the user navigate larger lists. |
| `static final int` | `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate#ALPHABETICAL_INDEXING_TITLE_AS_IS() = 1` Indicates that alphabetical indexing should use the item's title as-is with no processing. |
| `static final int` | `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate#ALPHABETICAL_INDEXING_TITLE_IGNORE_ARTICLES_AND_SYMBOLS() = 2` Indicates that alphabetical indexing should ignore English articles (like "the", "an", and "a") as well as non-alphanumeric symbols. |
| `static final int` | `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate#SCROLL_STATE_PRESERVE_INDEX() = 1` Indicate that the scroll position should be preserved by scrolling back down to the same index that the user had scrolled to. |
| `static final int` | `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate#SCROLL_STATE_RESET_TO_TOP() = 0` Indicate that the scroll position should reset back to the top when this template is refreshed. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate#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/util/List.html<https://developer.android.com/reference/androidx/car/app/model/Action>` | `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate#getActions()()` Returns the list of actions that should appear alongside the content of this template. |
| `int` | `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate#getAlphabeticalIndexingStrategy()()` Returns the alphabetical indexing strategy. |
| `@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/SectionedItemTemplate#getHeader()()` Returns the optional header for this template. |
| `int` | `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate#getScrollStatePersistenceStrategy()()` Returns the strategy to use when this template is used as a refresh. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/SearchHeader` | `@https://developer.android.com/reference/androidx/car/app/annotations/ExperimentalCarApi @https://developer.android.com/reference/androidx/car/app/annotations/RequiresCarApi(value = 9) https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate#getSearchHeader()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/SearchHeader` for this template or `null` if not set. |
| `@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/Section<@https://developer.android.com/reference/androidx/annotation/NonNull ?>>` | `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate#getSections()()` Returns the list of sections within this template. |
| `int` | `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate#hashCode()()` |
| `boolean` | `[isAlphabeticalIndexingAllowed](https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate#isAlphabeticalIndexingAllowed())()` **This method is deprecated.** use `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate#getAlphabeticalIndexingStrategy()` with `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate.Builder#setAlphabeticalIndexingStrategy(int)` <br /> |
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate#isLoading()()` Returns whether or not this template is in a loading state. |
| `@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/SectionedItemTemplate#toString()()` |

## Constants

### ALPHABETICAL_INDEXING_DISABLED

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

```
public static final int ALPHABETICAL_INDEXING_DISABLED = 0
```

Indicate that alphabetical indexing should not be available for the template which also disables any UI accelerators that the user may be shown to help the user navigate larger lists.

This is the default behavior if not explicitly set.

### ALPHABETICAL_INDEXING_TITLE_AS_IS

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

```
public static final int ALPHABETICAL_INDEXING_TITLE_AS_IS = 1
```

Indicates that alphabetical indexing should use the item's title as-is with no processing.

Note that a UI accelerator may still group the item under the "miscellaneous" category if the title starts with a non-alphabetical character.

### ALPHABETICAL_INDEXING_TITLE_IGNORE_ARTICLES_AND_SYMBOLS

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

```
public static final int ALPHABETICAL_INDEXING_TITLE_IGNORE_ARTICLES_AND_SYMBOLS = 2
```

Indicates that alphabetical indexing should ignore English articles (like "the", "an", and "a") as well as non-alphanumeric symbols.

Note this will not change the display of the item's title, just how it's sorted. For example, "The Example Song" will continue to show up as "The Example Song", but will be sorted into the "E" bucket.

### SCROLL_STATE_PRESERVE_INDEX

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

```
public static final int SCROLL_STATE_PRESERVE_INDEX = 1
```

Indicate that the scroll position should be preserved by scrolling back down to the same index that the user had scrolled to.

If the index no longer exists, the scroll position will be set to the bottom of the new list.

### SCROLL_STATE_RESET_TO_TOP

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

```
public static final int SCROLL_STATE_RESET_TO_TOP = 0
```

Indicate that the scroll position should reset back to the top when this template is refreshed.

This is the default behavior if not explicitly set.

## Public methods

### equals

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

### getActions

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

```
public @NonNull List<Action> getActions()
```

Returns the list of actions that should appear alongside the content of this template.

### getAlphabeticalIndexingStrategy

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

```
public int getAlphabeticalIndexingStrategy()
```

Returns the alphabetical indexing strategy.

"Indexing" refers to the process of examining list contents (e.g. item titles) to sort, partition, or filter a list. Indexing is generally used for features called "Accelerators", which allow a user to quickly find a particular `https://developer.android.com/reference/androidx/car/app/model/Item` in a long list.

Individual items may be excluded from the list by setting their `#isIndexable` field to `false`.

### getHeader

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

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

Returns the optional header for this template.

### getScrollStatePersistenceStrategy

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

```
public int getScrollStatePersistenceStrategy()
```

Returns the strategy to use when this template is used as a refresh. See `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate.Builder#setScrollStatePersistenceStrategy(int)`

### getSearchHeader

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

```
@ExperimentalCarApi
@RequiresCarApi(value = 9)
public @Nullable SearchHeader getSearchHeader()
```

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

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate.Builder#setSearchHeader(androidx.car.app.model.SearchHeader)` |   |

### getSections

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

```
public @NonNull List<Section<@NonNull ?>> getSections()
```

Returns the list of sections within this template.

### hashCode

```
public int hashCode()
```

### isAlphabeticalIndexingAllowed

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

```
public boolean [isAlphabeticalIndexingAllowed](https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate#isAlphabeticalIndexingAllowed())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> use `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate#getAlphabeticalIndexingStrategy()` with `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate.Builder#setAlphabeticalIndexingStrategy(int)`

Returns whether this list can be indexed alphabetically, by item title.

"Indexing" refers to the process of examining list contents (e.g. item titles) to sort, partition, or filter a list. Indexing is generally used for features called "Accelerators", which allow a user to quickly find a particular `https://developer.android.com/reference/androidx/car/app/model/Item` in a long list.

To exclude a single item from indexing, see the relevant item's API.

To enable/disable accelerators for the entire list, see `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate.Builder#setAlphabeticalIndexingAllowed(boolean)`

### isLoading

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

```
public boolean isLoading()
```

Returns whether or not this template is in a loading state.

### toString

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