# 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
class CondensedItem.Builder
```

<br />

*** ** * ** ***

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

## Summary

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

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

## Public constructors

### Builder

Added in 1.8.0

```
Builder()
```

## Public functions

### build

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

```
fun build(): CondensedItem
```

Constructs a `https://developer.android.com/reference/kotlin/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)

```
fun setIndexable(indexable: Boolean): CondensedItem.Builder
```

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
fun setLeadingImage(image: CarIcon): CondensedItem.Builder
```

Sets the leading image of the item.

The leading image will default to `https://developer.android.com/reference/kotlin/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
fun setLeadingImage(image: CarIcon, imageType: Int): CondensedItem.Builder
```

Sets the leading image of the item.

| Parameters |
|---|---|
| `image: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` | the `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` for the leading image |
| `imageType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the `https://developer.android.com/reference/kotlin/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
fun setOnClickListener(onClickListener: OnClickListener): CondensedItem.Builder
```

Sets the `https://developer.android.com/reference/kotlin/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
fun setProgressBar(progressBar: CarProgressBar): CondensedItem.Builder
```

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

**Note:** This field is mutually exclusive with `https://developer.android.com/reference/kotlin/androidx/car/app/model/CondensedItem.Builder#setText(java.lang.CharSequence)`. If both are set, `https://developer.android.com/reference/kotlin/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
fun setStyle(style: CondensedItemStyle): CondensedItem.Builder
```

Sets the `https://developer.android.com/reference/kotlin/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
fun setText(text: CarText): CondensedItem.Builder
```

Sets the text of the item.

`text` must conform to .

**Note:** This field is mutually exclusive with `https://developer.android.com/reference/kotlin/androidx/car/app/model/CondensedItem.Builder#setProgressBar(androidx.car.app.model.CarProgressBar)`. If both are set, `https://developer.android.com/reference/kotlin/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
fun setText(text: CharSequence): CondensedItem.Builder
```

Sets the text of the item.

`text` must conform to .

**Note:** This field is mutually exclusive with `https://developer.android.com/reference/kotlin/androidx/car/app/model/CondensedItem.Builder#setProgressBar(androidx.car.app.model.CarProgressBar)`. If both are set, `https://developer.android.com/reference/kotlin/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
fun setTitle(title: CarText): CondensedItem.Builder
```

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
fun setTitle(title: CharSequence): CondensedItem.Builder
```

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
fun setTrailingImage(image: CarIcon): CondensedItem.Builder
```

Sets the trailing image of the item.

The trailing image will default to `https://developer.android.com/reference/kotlin/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
fun setTrailingImage(image: CarIcon, imageType: Int): CondensedItem.Builder
```

Sets the trailing image of the item.

| Parameters |
|---|---|
| `image: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` | the `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` for the trailing image |
| `imageType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the `https://developer.android.com/reference/kotlin/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 |