# ItemList

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

*** ** * ** ***


```
@CarProtocol
public final class ItemList
```

<br />

*** ** * ** ***

Represents a list of `https://developer.android.com/reference/androidx/car/app/model/Item` instances. `https://developer.android.com/reference/androidx/car/app/model/ItemList` instances are used by templates that contain lists of models, such as for example, the list of `https://developer.android.com/reference/androidx/car/app/model/Row`s in a `https://developer.android.com/reference/androidx/car/app/model/ListTemplate`.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/car/app/model/ItemList.Builder` A builder of `https://developer.android.com/reference/androidx/car/app/model/ItemList`. |
| `public interface https://developer.android.com/reference/androidx/car/app/model/ItemList.OnItemVisibilityChangedListener` A listener for handling item visibility changes. |
| `public interface https://developer.android.com/reference/androidx/car/app/model/ItemList.OnSelectedListener` A listener for handling selection events for lists with selectable items. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/ItemList#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/Item>` | `https://developer.android.com/reference/androidx/car/app/model/ItemList#getItems()()` Returns the list of items in this `https://developer.android.com/reference/androidx/car/app/model/ItemList`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarText` | `https://developer.android.com/reference/androidx/car/app/model/ItemList#getNoItemsMessage()()` Returns the app-supplied text to be displayed if the list is empty or `null` if the default text will be used by the host. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/OnItemVisibilityChangedDelegate` | `https://developer.android.com/reference/androidx/car/app/model/ItemList#getOnItemVisibilityChangedDelegate()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/OnItemVisibilityChangedDelegate` to be called when the visible items in the list changes 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/OnSelectedDelegate` | `https://developer.android.com/reference/androidx/car/app/model/ItemList#getOnSelectedDelegate()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/OnSelectedDelegate` to be called when when an item is selected by the user or `null` is the list is non-selectable. |
| `int` | `https://developer.android.com/reference/androidx/car/app/model/ItemList#getSelectedIndex()()` Returns the index of the selected item of the list. |
| `int` | `https://developer.android.com/reference/androidx/car/app/model/ItemList#hashCode()()` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/ItemList.Builder` | `https://developer.android.com/reference/androidx/car/app/model/ItemList#toBuilder()()` Creates and returns a new `https://developer.android.com/reference/androidx/car/app/model/ItemList.Builder` initialized with this `https://developer.android.com/reference/androidx/car/app/model/ItemList`'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/ItemList#toString()()` |

## Public methods

### equals

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

### getItems

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

```
public @NonNull List<Item> getItems()
```

Returns the list of items in this `https://developer.android.com/reference/androidx/car/app/model/ItemList`.

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

### getNoItemsMessage

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

```
public @Nullable CarText getNoItemsMessage()
```

Returns the app-supplied text to be displayed if the list is empty or `null` if the default text will be used by the host.

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

### getOnItemVisibilityChangedDelegate

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

```
public @Nullable OnItemVisibilityChangedDelegate getOnItemVisibilityChangedDelegate()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/OnItemVisibilityChangedDelegate` to be called when the visible items in the list changes or `null` if one hasn't been set.

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

### getOnSelectedDelegate

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

```
public @Nullable OnSelectedDelegate getOnSelectedDelegate()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/OnSelectedDelegate` to be called when when an item is selected by the user or `null` is the list is non-selectable.

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

### getSelectedIndex

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

```
public int getSelectedIndex()
```

Returns the index of the selected item of the list.

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

### hashCode

```
public int hashCode()
```

### toBuilder

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

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

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

### toString

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