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

*** ** * ** ***


```
@RequiresCarApi(value = 9)
@ExperimentalCarApi
class Banner.Builder
```

<br />

*** ** * ** ***

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

## Summary

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

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder#addBelowAction(androidx.car.app.model.Action)(action: https://developer.android.com/reference/kotlin/androidx/car/app/model/Action)` Adds an `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` below the title and subtitle of the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner`. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder#addTrailingAction(androidx.car.app.model.Action)(action: https://developer.android.com/reference/kotlin/androidx/car/app/model/Action)` Adds an `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` to the trailing part of the banner. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder#addTrailingImage(androidx.car.app.model.CarIcon)(image: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon)` Adds a `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` to be displayed as an `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner#IMAGE_TYPE_MEDIUM()` image at the trailing part of the Banner, not expected to be tinted. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder#addTrailingImage(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)` Adds a `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` to be displayed as an image to the trailing part of the banner. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder#build()()` Constructs the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner` defined by this builder. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder#setLeadingImage(androidx.car.app.model.CarIcon)(image: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon)` Sets the leading element in this banner to be a `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` displayed as an `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner#IMAGE_TYPE_MEDIUM()` image, not expected to be tinted. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.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 element in this banner to be a `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` displayed as an image. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.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` to be called back when the banner is clicked. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder#setStyle(androidx.car.app.model.BannerStyle)(style: https://developer.android.com/reference/kotlin/androidx/car/app/model/BannerStyle)` Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/BannerStyle` of the banner. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder#setSubtitle(androidx.car.app.model.CarText)(subtitle: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText)` Sets the subtitle of the banner. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder#setSubtitle(java.lang.CharSequence)(subtitle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)` Sets the subtitle of the banner. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder#setTitle(androidx.car.app.model.CarText)(title: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText)` Sets the title of the banner. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder#setTitle(java.lang.CharSequence)(title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)` Sets the title of the banner. |

## Public constructors

### Builder

Added in 1.9.0-alpha03

```
Builder()
```

## Public functions

### addBelowAction

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

```
fun addBelowAction(action: Action): Banner.Builder
```

Adds an `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` below the title and subtitle of the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner`.

A `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner`'s below actions must conform to .

Below actions cannot be used in combination with a large image.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `action` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `action` does not conform to |

### addTrailingAction

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

```
fun addTrailingAction(action: Action): Banner.Builder
```

Adds an `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` to the trailing part of the banner.

A banner can have at most 2 trailing elements.

`action` must conform to .

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `action` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if there are already 2 trailing elements |

### addTrailingImage

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

```
fun addTrailingImage(image: CarIcon): Banner.Builder
```

Adds a `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` to be displayed as an `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner#IMAGE_TYPE_MEDIUM()` image at the trailing part of the Banner, not expected to be tinted.

A banner can have at most 2 trailing elements.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `image` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if there are already 2 trailing elements |

### addTrailingImage

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

```
fun addTrailingImage(image: CarIcon, imageType: Int): Banner.Builder
```

Adds a `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` to be displayed as an image to the trailing part of the banner.

A banner can have at most 2 trailing elements.

A large image cannot be used in combination with `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder#addBelowAction(androidx.car.app.model.Action)`.

A large trailing image cannot be used in combination with another large trailing image.

| 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` | one of `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner#IMAGE_TYPE_SMALL()`, `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner#IMAGE_TYPE_MEDIUM()`, `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner#IMAGE_TYPE_LARGE()` |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `image` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if there are already 2 trailing elements |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if a large trailing image is combined with anything other than a trailing small image or action |

### build

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

```
fun build(): Banner
```

Constructs the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner` defined by this builder.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the title is null or empty |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if below actions are used in combination with a large image |

### setLeadingImage

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

```
fun setLeadingImage(image: CarIcon): Banner.Builder
```

Sets the leading element in this banner to be a `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` displayed as an `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner#IMAGE_TYPE_MEDIUM()` image, not expected to be tinted.

Only a single leading image can be set. Subsequent calls will overwrite previous calls.

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

### setLeadingImage

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

```
fun setLeadingImage(image: CarIcon, imageType: Int): Banner.Builder
```

Sets the leading element in this banner to be a `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` displayed as an image.

Only a single leading icon or image can be set. Subsequent calls will overwrite previous calls.

A large image cannot be used in combination with `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner.Builder#addBelowAction(androidx.car.app.model.Action)`.

| 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` | one of `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner#IMAGE_TYPE_SMALL()`, `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner#IMAGE_TYPE_MEDIUM()`, `https://developer.android.com/reference/kotlin/androidx/car/app/model/Banner#IMAGE_TYPE_LARGE()` |

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

### setOnClickListener

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

```
fun setOnClickListener(onClickListener: OnClickListener): Banner.Builder
```

Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/OnClickListener` to be called back when the banner is clicked.

Note that the listener relates to UI events and will be executed on the main thread using `https://developer.android.com/reference/android/os/Looper.html#getMainLooper()`.

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

### setStyle

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

```
fun setStyle(style: BannerStyle): Banner.Builder
```

Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/BannerStyle` of the banner.

If a style is not provided via this method, a host default style will be used.

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

### setSubtitle

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

```
fun setSubtitle(subtitle: CarText): Banner.Builder
```

Sets the subtitle of the banner.

The subtitle allows spans to be added.

The subtitle is automatically truncated if it's too long.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `subtitle` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if any unsupported span types are added |

### setSubtitle

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

```
fun setSubtitle(subtitle: CharSequence): Banner.Builder
```

Sets the subtitle of the banner.

The subtitle allows spans to be added.

The subtitle is automatically truncated if it's too long.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `subtitle` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if any unsupported span types are added |

### setTitle

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

```
fun setTitle(title: CarText): Banner.Builder
```

Sets the title of the banner.

The title allows spans to be added.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `title` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if any unsupported span types are added |

### setTitle

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

```
fun setTitle(title: CharSequence): Banner.Builder
```

Sets the title of the banner.

The title allows spans to be added.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `title` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if any unsupported span types are added |