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

*** ** * ** ***


```
class SearchHeader.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchHeader.Builder#Builder(androidx.car.app.model.SearchCallback)(callback: https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchCallback)` Creates a new `https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchHeader.Builder` with provided search callback `https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchCallback`. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchHeader` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchHeader.Builder#build()()` Constructs the `https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchHeader` instance. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchHeader.Builder#setEndHeaderActions(java.util.List<androidx.car.app.model.Action>)(endHeaderActions: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<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 be displayed at the end of the header. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchHeader.Builder#setInitialSearchText(java.lang.String)(initialSearchText: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Sets the initial search text to display in the search box. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchHeader.Builder#setSearchHint(java.lang.String)(searchHint: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Sets the text hint to display in the search box when it is empty. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchHeader.Builder#setShowKeyboardByDefault(boolean)(showKeyboardByDefault: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether the keyboard should be displayed by default. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchHeader.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchHeader.Builder#setStartHeaderAction(androidx.car.app.model.Action)(headerAction: https://developer.android.com/reference/kotlin/androidx/car/app/model/Action)` Sets the start header `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`. |

## Public constructors

### Builder

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

```
Builder(callback: SearchCallback)
```

Creates a new `https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchHeader.Builder` with provided search callback `https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchCallback`.

| Parameters |
|---|---|
| `callback: https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchCallback` | the callback to be invoked for search events |

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

## Public functions

### build

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

```
fun build(): SearchHeader
```

Constructs the `https://developer.android.com/reference/kotlin/androidx/car/app/model/SearchHeader` instance.

### setEndHeaderActions

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

```
@CanIgnoreReturnValue
fun setEndHeaderActions(endHeaderActions: (Mutable)List<Action!>): SearchHeader.Builder
```

Adds an `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` to be displayed at the end of the header.

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

### setInitialSearchText

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

```
@CanIgnoreReturnValue
fun setInitialSearchText(initialSearchText: String): SearchHeader.Builder
```

Sets the initial search text to display in the search box.

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

### setSearchHint

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

```
@CanIgnoreReturnValue
fun setSearchHint(searchHint: String): SearchHeader.Builder
```

Sets the text hint to display in the search box when it is empty.

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

### setShowKeyboardByDefault

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

```
@CanIgnoreReturnValue
fun setShowKeyboardByDefault(showKeyboardByDefault: Boolean): SearchHeader.Builder
```

Sets whether the keyboard should be displayed by default. Defaults to `true`.

### setStartHeaderAction

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

```
@CanIgnoreReturnValue
fun setStartHeaderAction(headerAction: Action): SearchHeader.Builder
```

Sets the start header `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `headerAction` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `headerAction` does not meet the |