# SearchTemplate

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

*** ** * ** ***


```
@CarProtocol
public final class SearchTemplate implements Template
```

<br />

*** ** * ** ***

A model that allows the user to enter text searches, and can display results in a list.

#### Template Restrictions

In regards to template refreshes, as described in `https://developer.android.com/reference/androidx/car/app/Screen#onGetTemplate()`, this template supports any content changes as refreshes. This allows apps to interactively update the search results as the user types without the templates being counted against the quota.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/car/app/model/SearchTemplate.Builder` A builder of `https://developer.android.com/reference/androidx/car/app/model/SearchTemplate`. |
| `public interface https://developer.android.com/reference/androidx/car/app/model/SearchTemplate.SearchCallback` A listener for search updates. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/SearchTemplate#equals(java.lang.Object)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html other)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/ActionStrip` | `https://developer.android.com/reference/androidx/car/app/model/SearchTemplate#getActionStrip()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/ActionStrip` for this template or `null` if not set. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/Action` | `https://developer.android.com/reference/androidx/car/app/model/SearchTemplate#getHeaderAction()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/Action` that is set to be displayed in the header of the template, or `null` if not set. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/car/app/model/SearchTemplate#getInitialSearchText()()` Returns the optional initial search text. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/ItemList` | `https://developer.android.com/reference/androidx/car/app/model/SearchTemplate#getItemList()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/ItemList` for search results or `null` if not set. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/SearchCallbackDelegate` | `https://developer.android.com/reference/androidx/car/app/model/SearchTemplate#getSearchCallbackDelegate()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/SearchCallbackDelegate` for search callbacks. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/car/app/model/SearchTemplate#getSearchHint()()` Returns the optional search hint. |
| `int` | `https://developer.android.com/reference/androidx/car/app/model/SearchTemplate#hashCode()()` |
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/SearchTemplate#isLoading()()` Returns whether the template is loading. |
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/SearchTemplate#isShowKeyboardByDefault()()` Returns whether to show the keyboard by default. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/car/app/model/SearchTemplate#toString()()` |

## Public methods

### equals

```
public boolean equals(@Nullable Object other)
```

### getActionStrip

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

```
public @Nullable ActionStrip getActionStrip()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/ActionStrip` for this template or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/SearchTemplate.Builder#setActionStrip(androidx.car.app.model.ActionStrip)` |   |

### getHeaderAction

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

```
public @Nullable Action getHeaderAction()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/Action` that is set to be displayed in the header of the template, or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/SearchTemplate.Builder#setHeaderAction(androidx.car.app.model.Action)` |   |

### getInitialSearchText

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

```
public @Nullable String getInitialSearchText()
```

Returns the optional initial search text.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/SearchTemplate.Builder#setInitialSearchText(java.lang.String)` |   |

### getItemList

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

```
public @Nullable ItemList getItemList()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/ItemList` for search results or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/SearchTemplate#getItemList()` |   |

### getSearchCallbackDelegate

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

```
public @NonNull SearchCallbackDelegate getSearchCallbackDelegate()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/SearchCallbackDelegate` for search callbacks.

### getSearchHint

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

```
public @Nullable String getSearchHint()
```

Returns the optional search hint.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/SearchTemplate.Builder#setSearchHint(java.lang.String)` |   |

### hashCode

```
public int hashCode()
```

### isLoading

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

```
public boolean isLoading()
```

Returns whether the template is loading.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/SearchTemplate.Builder#setLoading(boolean)` |   |

### isShowKeyboardByDefault

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

```
public boolean isShowKeyboardByDefault()
```

Returns whether to show the keyboard by default.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/SearchTemplate.Builder#setShowKeyboardByDefault(boolean)` |   |

### toString

```
public @NonNull String toString()
```