# CondensedItem.Builder

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

*** ** * ** ***


```
@RequiresCarApi(value = 9)
@ExperimentalCarApi
public final class CondensedItem.Builder
```

<br />

*** ** * ** ***

A builder for `https://developer.android.com/reference/androidx/car/app/model/CondensedItem`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#Builder()()` |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem` | `https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#build()()` Constructs a `https://developer.android.com/reference/androidx/car/app/model/CondensedItem` from the current state of this builder. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder` | `https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#setIndexable(boolean)(boolean indexable)` Sets whether this item can be included in indexed lists. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#setLeadingImage(androidx.car.app.model.CarIcon)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarIcon image)` Sets the leading image of the item. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#setLeadingImage(androidx.car.app.model.CarIcon,int)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarIcon image, int imageType)` Sets the leading image of the item. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#setOnClickListener(androidx.car.app.model.OnClickListener)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/OnClickListener onClickListener)` Sets the `https://developer.android.com/reference/androidx/car/app/model/OnClickListener` for the item. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#setProgressBar(androidx.car.app.model.CarProgressBar)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarProgressBar progressBar)` Sets the `https://developer.android.com/reference/androidx/car/app/model/CarProgressBar` for the item. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#setStyle(androidx.car.app.model.CondensedItemStyle)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CondensedItemStyle style)` Sets the `https://developer.android.com/reference/androidx/car/app/model/CondensedItemStyle` for the item. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#setText(androidx.car.app.model.CarText)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarText text)` Sets the text of the item. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#setText(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html text)` Sets the text of the item. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#setTitle(androidx.car.app.model.CarText)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarText title)` Sets the title of the item. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#setTitle(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html title)` Sets the title of the item. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#setTrailingImage(androidx.car.app.model.CarIcon)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarIcon image)` Sets the trailing image of the item. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#setTrailingImage(androidx.car.app.model.CarIcon,int)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarIcon image, int imageType)` Sets the trailing image of the item. |

## Public constructors

### Builder

Added in 1.8.0

```
public Builder()
```

## Public methods

### build

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

```
public @NonNull CondensedItem build()
```

Constructs a `https://developer.android.com/reference/androidx/car/app/model/CondensedItem` from the current state of this builder.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if `mTitle`, `mText`, `mLeadingImage`, AND `mTrailingImage` are all `null`. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if both `mText` and `mProgressBar` are set. |

### setIndexable

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

```
public @NonNull CondensedItem.Builder setIndexable(boolean indexable)
```

Sets whether this item can be included in indexed lists. By default, this is set to `true`.

The host creates indexed lists to help users navigate through long lists more easily by sorting, filtering, or some other means.

For example, a media app may, by default, show a user's playlists sorted by date created. If the app provides these playlists via the `SectionedItemTemplate` and enables `#isAlphabeticalIndexingAllowed`, the user will be able to select a letter on a keyboard to jump to their playlists that start with that letter. When this happens, the list is reconstructed and sorted alphabetically, then shown to the user, jumping down to the letter. Items that are set to `#setIndexable(false)`, do not show up in this new sorted list. Sticking with the media example, a media app may choose to hide things like "autogenerated playlists" from the list and only keep user created playlists.

Individual items can be set to be included or excluded from filtered lists, but it's also possible to enable/disable the creation of filtered lists as a whole via the template's API (eg. `SectionedItemTemplate
.Builder#setAlphabeticalIndexingStrategy(int)`).

### setLeadingImage

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

```
@CanIgnoreReturnValue
public @NonNull CondensedItem.Builder setLeadingImage(@NonNull CarIcon image)
```

Sets the leading image of the item.

The leading image will default to `https://developer.android.com/reference/androidx/car/app/model/CondensedItem#IMAGE_TYPE_MEDIUM()`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `image` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `image` contains unsupported icon types |

### setLeadingImage

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

```
@CanIgnoreReturnValue
public @NonNull CondensedItem.Builder setLeadingImage(@NonNull CarIcon image, int imageType)
```

Sets the leading image of the item.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarIcon image` | the `https://developer.android.com/reference/androidx/car/app/model/CarIcon` for the leading image |
| `int imageType` | the `https://developer.android.com/reference/androidx/car/app/model/CondensedItem.CondensedItemImageType` for the leading image |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `image` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `image` contains unsupported icon types |

### setOnClickListener

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

```
@CanIgnoreReturnValue
public @NonNull CondensedItem.Builder setOnClickListener(@NonNull OnClickListener onClickListener)
```

Sets the `https://developer.android.com/reference/androidx/car/app/model/OnClickListener` for the item.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `onClickListener` is `null` |

### setProgressBar

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

```
@CanIgnoreReturnValue
public @NonNull CondensedItem.Builder setProgressBar(@NonNull CarProgressBar progressBar)
```

Sets the `https://developer.android.com/reference/androidx/car/app/model/CarProgressBar` for the item.

**Note:** This field is mutually exclusive with `https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#setText(java.lang.CharSequence)`. If both are set, `https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#build()` will throw an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `progressBar` is `null` |

### setStyle

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

```
@CanIgnoreReturnValue
public @NonNull CondensedItem.Builder setStyle(@NonNull CondensedItemStyle style)
```

Sets the `https://developer.android.com/reference/androidx/car/app/model/CondensedItemStyle` for the item.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `style` is `null` |

### setText

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

```
@CanIgnoreReturnValue
public @NonNull CondensedItem.Builder setText(@NonNull CarText text)
```

Sets the text of the item.

`text` must conform to .

**Note:** This field is mutually exclusive with `https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#setProgressBar(androidx.car.app.model.CarProgressBar)`. If both are set, `https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#build()` will throw an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `text` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `text` contains unsupported spans |

### setText

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

```
@CanIgnoreReturnValue
public @NonNull CondensedItem.Builder setText(@NonNull CharSequence text)
```

Sets the text of the item.

`text` must conform to .

**Note:** This field is mutually exclusive with `https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#setProgressBar(androidx.car.app.model.CarProgressBar)`. If both are set, `https://developer.android.com/reference/androidx/car/app/model/CondensedItem.Builder#build()` will throw an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `text` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `text` contains unsupported spans |

### setTitle

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

```
@CanIgnoreReturnValue
public @NonNull CondensedItem.Builder setTitle(@NonNull CarText title)
```

Sets the title of the item.

`title` must conform to .

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `title` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `title` contains unsupported spans |

### setTitle

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

```
@CanIgnoreReturnValue
public @NonNull CondensedItem.Builder setTitle(@NonNull CharSequence title)
```

Sets the title of the item.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `title` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `title` contains unsupported spans |

### setTrailingImage

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

```
@CanIgnoreReturnValue
public @NonNull CondensedItem.Builder setTrailingImage(@NonNull CarIcon image)
```

Sets the trailing image of the item.

The trailing image will default to `https://developer.android.com/reference/androidx/car/app/model/CondensedItem#IMAGE_TYPE_MEDIUM()`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `image` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `image` contains unsupported icon types |

### setTrailingImage

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

```
@CanIgnoreReturnValue
public @NonNull CondensedItem.Builder setTrailingImage(@NonNull CarIcon image, int imageType)
```

Sets the trailing image of the item.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarIcon image` | the `https://developer.android.com/reference/androidx/car/app/model/CarIcon` for the trailing image |
| `int imageType` | the `https://developer.android.com/reference/androidx/car/app/model/CondensedItem.CondensedItemImageType` for the trailing image |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `image` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `image` contains unsupported icon types |