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

*** ** * ** ***


```
public final class SearchHeader.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/car/app/model/SearchHeader.Builder#Builder(androidx.car.app.model.SearchCallback)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/SearchCallback callback)` Creates a new `https://developer.android.com/reference/androidx/car/app/model/SearchHeader.Builder` with provided search callback `https://developer.android.com/reference/androidx/car/app/model/SearchCallback`. |

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

```
public Builder(@NonNull SearchCallback callback)
```

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

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/SearchCallback callback` | the callback to be invoked for search events |

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

## Public methods

### build

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

```
public @NonNull SearchHeader build()
```

Constructs the `https://developer.android.com/reference/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
public @NonNull SearchHeader.Builder setEndHeaderActions(@NonNull List<Action> endHeaderActions)
```

Adds an `https://developer.android.com/reference/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
public @NonNull SearchHeader.Builder setInitialSearchText(@NonNull String initialSearchText)
```

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
public @NonNull SearchHeader.Builder setSearchHint(@NonNull String searchHint)
```

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
public @NonNull SearchHeader.Builder setShowKeyboardByDefault(boolean showKeyboardByDefault)
```

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
public @NonNull SearchHeader.Builder setStartHeaderAction(@NonNull Action headerAction)
```

Sets the start header `https://developer.android.com/reference/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 |