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

*** ** * ** ***


```
public final class SectionHeader.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder#Builder(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)` Returns a `https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder` instance configured with the given `title`. |
| `https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder#Builder(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html title)` Returns a `https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder` instance configured with the given `title`. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/SectionHeader` | `https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder#build()()` Builds the `https://developer.android.com/reference/androidx/car/app/model/SectionHeader`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder#setEndIcon(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 endIcon)` Sets the end icon of the header. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder#setHeadline(androidx.car.app.model.CarText)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarText headline)` Sets the headline of the header. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder#setHeadline(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html headline)` Sets the headline of the header. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/SectionHeader.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 click listener for the header. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder#setStartIcon(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 startIcon)` Sets the start icon of the header with a default size of `https://developer.android.com/reference/androidx/car/app/model/SectionHeader#IMAGE_TYPE_SMALL()`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder#setStartIcon(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 startIcon, int startIconType)` Sets the start icon of the header and its size type. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder#setSubtitle(androidx.car.app.model.CarText)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarText subtitle)` Sets the subtitle of the header. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/SectionHeader.Builder#setSubtitle(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html subtitle)` 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)

```
public Builder(@NonNull CarText title)
```

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

```
public Builder(@NonNull CharSequence title)
```

Returns a `https://developer.android.com/reference/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/androidx/car/app/model/CarText` |   |

## Public methods

### build

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

```
public @NonNull SectionHeader build()
```

Builds the `https://developer.android.com/reference/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
public @NonNull SectionHeader.Builder setEndIcon(@NonNull CarIcon endIcon)
```

Sets the end icon of the header.

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

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarIcon endIcon` | the `https://developer.android.com/reference/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
public @NonNull SectionHeader.Builder setHeadline(@Nullable CarText headline)
```

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/androidx/car/app/model/SectionHeader.Builder#build()` will throw an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarText headline` | 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/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
public @NonNull SectionHeader.Builder setHeadline(@NonNull CharSequence headline)
```

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/androidx/car/app/model/SectionHeader.Builder#build()` will throw an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html headline` | 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/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
public @NonNull SectionHeader.Builder setOnClickListener(@NonNull OnClickListener onClickListener)
```

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
public @NonNull SectionHeader.Builder setStartIcon(@NonNull CarIcon startIcon)
```

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

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

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarIcon startIcon` | the `https://developer.android.com/reference/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
public @NonNull SectionHeader.Builder setStartIcon(@NonNull CarIcon startIcon, int startIconType)
```

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

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

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarIcon startIcon` | the `https://developer.android.com/reference/androidx/car/app/model/CarIcon` to display before the title |
| `int startIconType` | the type of image to display. See `https://developer.android.com/reference/androidx/car/app/model/SectionHeader` for supported image types (e.g. `https://developer.android.com/reference/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
public @NonNull SectionHeader.Builder setSubtitle(@Nullable CarText subtitle)
```

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/androidx/car/app/model/SectionHeader.Builder#build()` will throw an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarText subtitle` | 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/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
public @NonNull SectionHeader.Builder setSubtitle(@Nullable CharSequence subtitle)
```

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/androidx/car/app/model/SectionHeader.Builder#build()` will throw an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html subtitle` | 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/androidx/car/app/model/CarText` |   |