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

*** ** * ** ***


```
class SectionHeader.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder#Builder(androidx.car.app.model.CarText)(title: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText)` Returns a `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder` instance configured with the given `title`. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder#Builder(java.lang.CharSequence)(title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)` Returns a `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder` instance configured with the given `title`. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder#build()()` Builds the `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader`. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder#setEndIcon(androidx.car.app.model.CarIcon)(endIcon: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon)` Sets the end icon of the header. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder#setHeadline(androidx.car.app.model.CarText)(headline: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText?)` Sets the headline of the header. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder#setHeadline(java.lang.CharSequence)(headline: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)` Sets the headline of the header. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder#setOnClickListener(androidx.car.app.model.OnClickListener)(onClickListener: https://developer.android.com/reference/kotlin/androidx/car/app/model/OnClickListener)` Sets the click listener for the header. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder#setStartIcon(androidx.car.app.model.CarIcon)(startIcon: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon)` Sets the start icon of the header with a default size of `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader#IMAGE_TYPE_SMALL()`. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder#setStartIcon(androidx.car.app.model.CarIcon,int)(startIcon: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon, startIconType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the start icon of the header and its size type. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder#setSubtitle(androidx.car.app.model.CarText)(subtitle: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText?)` Sets the subtitle of the header. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder#setSubtitle(java.lang.CharSequence)(subtitle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?)` Sets the subtitle of the header. |

## Public constructors

### Builder

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

```
Builder(title: CarText)
```

Returns a `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder` instance configured with the given `title`.

The title must be a plain string with no spans other than those supported by .

| 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 |

### Builder

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

```
Builder(title: CharSequence)
```

Returns a `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder` instance configured with the given `title`.

The title must be a plain string with no spans other than those supported by .

| 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 |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText` |   |

## Public functions

### build

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

```
fun build(): SectionHeader
```

Builds the `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if both headline and subtitle are set |

### setEndIcon

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

```
@CanIgnoreReturnValue
fun setEndIcon(endIcon: CarIcon): SectionHeader.Builder
```

Sets the end icon of the header.

Only custom icon types (e.g. `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon#TYPE_CUSTOM()`) are supported.

| Parameters |
|---|---|
| `endIcon: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` | the `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` to display after the title |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `endIcon` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `endIcon` is not a custom icon, or if it does not meet the constraints |

### setHeadline

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

```
@CanIgnoreReturnValue
fun setHeadline(headline: CarText?): SectionHeader.Builder
```

Sets the headline of the header.

The headline appears above the title as an eyebrow or overline. It must be a plain string with no spans other than those supported by .

A section header cannot have both a headline and a subtitle. If both are set, `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder#build()` will throw an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

| Parameters |
|---|---|
| `headline: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText?` | the headline to set |

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

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText` |   |

### setHeadline

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

```
@CanIgnoreReturnValue
fun setHeadline(headline: CharSequence): SectionHeader.Builder
```

Sets the headline of the header.

The headline appears above the title as an eyebrow or overline. It must be a plain string with no spans other than those supported by .

A section header cannot have both a headline and a subtitle. If both are set, `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder#build()` will throw an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

| Parameters |
|---|---|
| `headline: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html` | the headline to set |

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

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText` |   |

### 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): SectionHeader.Builder
```

Sets the click listener for the header.

If a listener is set, the header will become focusable and clickable.

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

### setStartIcon

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

```
@CanIgnoreReturnValue
fun setStartIcon(startIcon: CarIcon): SectionHeader.Builder
```

Sets the start icon of the header with a default size of `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader#IMAGE_TYPE_SMALL()`.

Only custom icon types (e.g. `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon#TYPE_CUSTOM()`) are supported.

| Parameters |
|---|---|
| `startIcon: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` | the `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` to display before the title |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `startIcon` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `startIcon` is not a custom icon, or if it does not meet the constraints |

### setStartIcon

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

```
@CanIgnoreReturnValue
fun setStartIcon(startIcon: CarIcon, startIconType: Int): SectionHeader.Builder
```

Sets the start icon of the header and its size type.

Only custom icon types (e.g. `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon#TYPE_CUSTOM()`) are supported.

| Parameters |
|---|---|
| `startIcon: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` | the `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` to display before the title |
| `startIconType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the type of image to display. See `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader` for supported image types (e.g. `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader#IMAGE_TYPE_SMALL()`). |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `startIcon` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `startIcon` is not a custom icon, or if it does not meet the constraints |

### setSubtitle

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

```
@CanIgnoreReturnValue
fun setSubtitle(subtitle: CarText?): SectionHeader.Builder
```

Sets the subtitle of the header.

The subtitle appears below the title. It must be a plain string with no spans other than those supported by .

A section header cannot have both a headline and a subtitle. If both are set, `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder#build()` will throw an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

| Parameters |
|---|---|
| `subtitle: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText?` | the subtitle to set |

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

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText` |   |

### setSubtitle

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

```
@CanIgnoreReturnValue
fun setSubtitle(subtitle: CharSequence?): SectionHeader.Builder
```

Sets the subtitle of the header.

The subtitle appears below the title. It must be a plain string with no spans other than those supported by .

A section header cannot have both a headline and a subtitle. If both are set, `https://developer.android.com/reference/kotlin/androidx/car/app/model/SectionHeader.Builder#build()` will throw an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

| Parameters |
|---|---|
| `subtitle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html?` | the subtitle to set |

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

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText` |   |