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

*** ** * ** ***


```
class RoutePreviewNavigationTemplate.Builder
```

<br />

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
> Deprecated in Java

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

## Summary

| ### Public constructors |
|---|
| `[Builder](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#Builder())()` **This function is deprecated.** Deprecated in Java |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate` | `[build](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#build())()` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `[setActionStrip](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setActionStrip(androidx.car.app.model.ActionStrip))(actionStrip: https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip)` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `@https://developer.android.com/reference/kotlin/androidx/car/app/annotations/RequiresCarApi(value = 5) [setHeader](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setHeader(androidx.car.app.model.Header))(header: https://developer.android.com/reference/kotlin/androidx/car/app/model/Header)` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `[setHeaderAction](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setHeaderAction(androidx.car.app.model.Action))(headerAction: https://developer.android.com/reference/kotlin/androidx/car/app/model/Action)` **This function is deprecated.** use `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setHeader(androidx.car.app.model.Header)` <br /> |
| `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `[setItemList](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setItemList(androidx.car.app.model.ItemList))(itemList: https://developer.android.com/reference/kotlin/androidx/car/app/model/ItemList)` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `[setLoading](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setLoading(boolean))(isLoading: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `@https://developer.android.com/reference/kotlin/androidx/car/app/annotations/RequiresCarApi(value = 4) [setMapActionStrip](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setMapActionStrip(androidx.car.app.model.ActionStrip))(actionStrip: https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip)` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `[setNavigateAction](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setNavigateAction(androidx.car.app.model.Action))(navigateAction: https://developer.android.com/reference/kotlin/androidx/car/app/model/Action)` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `@https://developer.android.com/reference/kotlin/androidx/car/app/annotations/RequiresCarApi(value = 4) [setPanModeListener](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setPanModeListener(androidx.car.app.navigation.model.PanModeListener))(panModeListener: https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/PanModeListener)` **This function is deprecated.** Deprecated in Java |
| `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `[setTitle](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setTitle(androidx.car.app.model.CarText))(title: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText)` **This function is deprecated.** use `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setHeader(androidx.car.app.model.Header)` <br /> |
| `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `[setTitle](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setTitle(java.lang.CharSequence))(title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html)` **This function is deprecated.** use `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setHeader(androidx.car.app.model.Header)` <br /> |

## Public constructors

### Builder

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

```
[Builder](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#Builder())()
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Constructs an empty `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` instance.

## Public functions

### build

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

```
fun [build](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#build())(): RoutePreviewNavigationTemplate
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Constructs the template defined by this builder.

#### Requirements

If neither header `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` nor title have been set on the template, the header is hidden.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if the template is in a loading state but the list is set or vice versa, or if the template is not loading and the navigation action is not set. |

### setActionStrip

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

```
fun [setActionStrip](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setActionStrip(androidx.car.app.model.ActionStrip))(actionStrip: ActionStrip): RoutePreviewNavigationTemplate.Builder
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip` for this template.

Unless set with this method, the template will not have an action strip.

The `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` buttons in Map Based Template are automatically adjusted based on the screen size. On narrow width screen, icon `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s show by default. If no icon specify, showing title `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s instead. On wider width screen, title `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s show by default. If no title specify, showing icon `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s instead.

#### Requirements

This template allows up to 4 `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s in its `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip`. Of the 4 allowed `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s, it can either be a title `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` as set via `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action.Builder#setTitle(java.lang.CharSequence)`, or a icon `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` as set via `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action.Builder#setIcon(androidx.car.app.model.CarIcon)`.

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

### setHeader

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

```
@RequiresCarApi(value = 5)
fun [setHeader](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setHeader(androidx.car.app.model.Header))(header: Header): RoutePreviewNavigationTemplate.Builder
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Header` for this template.

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

### setHeaderAction

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

```
fun [setHeaderAction](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setHeaderAction(androidx.car.app.model.Action))(headerAction: Action): RoutePreviewNavigationTemplate.Builder
```

> [!CAUTION]
> **This function is deprecated.**   
>
> use `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setHeader(androidx.car.app.model.Header)`

Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` that will be displayed in the header of the template, or `null` to not display an action.

Unless set with this method, the template will not have a header action.

#### Requirements

This template only supports either one of `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action#APP_ICON()` and `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action#BACK()` as a header `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`.

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

### setItemList

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

```
fun [setItemList](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setItemList(androidx.car.app.model.ItemList))(itemList: ItemList): RoutePreviewNavigationTemplate.Builder
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Sets an `https://developer.android.com/reference/kotlin/androidx/car/app/model/ItemList` to show route options in a list view along with the map.

#### Requirements

The number of items in the `https://developer.android.com/reference/kotlin/androidx/car/app/model/ItemList` should be smaller or equal than the limit provided by `https://developer.android.com/reference/kotlin/androidx/car/app/constraints/ConstraintManager#CONTENT_LIMIT_TYPE_ROUTE_LIST()`. The host will ignore any items over that limit. The list must have an `https://developer.android.com/reference/kotlin/androidx/car/app/model/OnClickListener` set. Each `https://developer.android.com/reference/kotlin/androidx/car/app/model/Row` can add up to 2 lines of texts via `https://developer.android.com/reference/kotlin/androidx/car/app/model/Row.Builder#addText(java.lang.CharSequence)` and cannot contain a `https://developer.android.com/reference/kotlin/androidx/car/app/model/Toggle`.

Images of type `https://developer.android.com/reference/kotlin/androidx/car/app/model/Row#IMAGE_TYPE_LARGE()` are not allowed in this template.

All rows must have either a `https://developer.android.com/reference/kotlin/androidx/car/app/model/DistanceSpan` or a `https://developer.android.com/reference/kotlin/androidx/car/app/model/DurationSpan` attached to either its title or texts, to indicate an estimate trip distance or duration for the route it represents. Where in the title or text these spans are attached to is up to the app.

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

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/constraints/ConstraintManager#getContentLimit(int)` |   |

### setLoading

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

```
fun [setLoading](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setLoading(boolean))(isLoading: Boolean): RoutePreviewNavigationTemplate.Builder
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Sets whether the template is in a loading state.

If set to `true`, the UI will show a loading indicator where the list content would be otherwise. The caller is expected to call `https://developer.android.com/reference/kotlin/androidx/car/app/Screen#invalidate()` and send the new template content to the host once the data is ready.

### setMapActionStrip

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

```
@RequiresCarApi(value = 4)
fun [setMapActionStrip](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setMapActionStrip(androidx.car.app.model.ActionStrip))(actionStrip: ActionStrip): RoutePreviewNavigationTemplate.Builder
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Sets an `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip` with a list of map-control related actions for this template, such as pan or zoom.

The host will draw the buttons in an area that is associated with map controls.

If the app does not include the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action#PAN()` button in this `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip`, the app will not receive the user input for panning gestures from `https://developer.android.com/reference/kotlin/androidx/car/app/SurfaceCallback` methods, and the host will exit any previously activated pan mode.

#### Requirements

This template allows up to 4 `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s in its map `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip`. Only `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`s with icons set via `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action.Builder#setIcon(androidx.car.app.model.CarIcon)` are allowed.

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

### setNavigateAction

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

```
fun [setNavigateAction](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setNavigateAction(androidx.car.app.model.Action))(navigateAction: Action): RoutePreviewNavigationTemplate.Builder
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` to allow users to request navigation using the currently selected route.

This should not be `null` if the template is not in a loading state (see #setIsLoading}), and the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action`'s title must be set.

Spans are not supported in the navigate action and will be ignored.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `navigateAction` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `navigateAction`'s title is `null` or empty |

### setPanModeListener

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

```
@RequiresCarApi(value = 4)
fun [setPanModeListener](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setPanModeListener(androidx.car.app.navigation.model.PanModeListener))(panModeListener: PanModeListener): RoutePreviewNavigationTemplate.Builder
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

Sets a `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/PanModeListener` that notifies when the user enters and exits the pan mode.

If the app does not include the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action#PAN()` button in the map `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip`, the app will not receive the user input for panning gestures from `https://developer.android.com/reference/kotlin/androidx/car/app/SurfaceCallback` methods, and the host will exit any previously activated pan mode.

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

### setTitle

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

```
fun [setTitle](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setTitle(androidx.car.app.model.CarText))(title: CarText): RoutePreviewNavigationTemplate.Builder
```

> [!CAUTION]
> **This function is deprecated.**   
>
> use `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setHeader(androidx.car.app.model.Header)`

Sets the title of the template, with support for multiple length variants.

Only `https://developer.android.com/reference/kotlin/androidx/car/app/model/DistanceSpan`s and `https://developer.android.com/reference/kotlin/androidx/car/app/model/DurationSpan`s are supported in the input string.

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

### setTitle

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

```
fun [setTitle](https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setTitle(java.lang.CharSequence))(title: CharSequence): RoutePreviewNavigationTemplate.Builder
```

> [!CAUTION]
> **This function is deprecated.**   
>
> use `https://developer.android.com/reference/kotlin/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setHeader(androidx.car.app.model.Header)`

Sets the title of the template.

Only `https://developer.android.com/reference/kotlin/androidx/car/app/model/DistanceSpan`s and `https://developer.android.com/reference/kotlin/androidx/car/app/model/DurationSpan`s are supported in the input string.

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