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

*** ** * ** ***


```
public final class RoutePreviewNavigationTemplate.Builder
```

<br />

*** ** * ** ***

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

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

## Summary

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

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate` | `[build](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#build())()` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `[setActionStrip](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setActionStrip(androidx.car.app.model.ActionStrip))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/ActionStrip actionStrip)` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `@https://developer.android.com/reference/androidx/car/app/annotations/RequiresCarApi(value = 5) [setHeader](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setHeader(androidx.car.app.model.Header))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/Header header)` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `[setHeaderAction](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setHeaderAction(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)` **This method is deprecated.** use `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setHeader(androidx.car.app.model.Header)` <br /> |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `[setItemList](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setItemList(androidx.car.app.model.ItemList))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/ItemList itemList)` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `[setLoading](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setLoading(boolean))(boolean isLoading)` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `@https://developer.android.com/reference/androidx/car/app/annotations/RequiresCarApi(value = 4) [setMapActionStrip](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setMapActionStrip(androidx.car.app.model.ActionStrip))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/ActionStrip actionStrip)` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `[setNavigateAction](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setNavigateAction(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 navigateAction)` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `@https://developer.android.com/reference/androidx/car/app/annotations/RequiresCarApi(value = 4) [setPanModeListener](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setPanModeListener(androidx.car.app.navigation.model.PanModeListener))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/PanModeListener panModeListener)` **This method is deprecated.** Deprecated in Java |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `[setTitle](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setTitle(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)` **This method is deprecated.** use `https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setHeader(androidx.car.app.model.Header)` <br /> |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder` | `[setTitle](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setTitle(java.lang.CharSequence))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html title)` **This method is deprecated.** use `https://developer.android.com/reference/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)

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

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

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

## Public methods

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

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

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

Constructs the template defined by this builder.

#### Requirements

If neither header `https://developer.android.com/reference/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)

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

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

Sets the `https://developer.android.com/reference/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/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/androidx/car/app/model/Action`s show by default. If no icon specify, showing title `https://developer.android.com/reference/androidx/car/app/model/Action`s instead. On wider width screen, title `https://developer.android.com/reference/androidx/car/app/model/Action`s show by default. If no title specify, showing icon `https://developer.android.com/reference/androidx/car/app/model/Action`s instead.

#### Requirements

This template allows up to 4 `https://developer.android.com/reference/androidx/car/app/model/Action`s in its `https://developer.android.com/reference/androidx/car/app/model/ActionStrip`. Of the 4 allowed `https://developer.android.com/reference/androidx/car/app/model/Action`s, it can either be a title `https://developer.android.com/reference/androidx/car/app/model/Action` as set via `https://developer.android.com/reference/androidx/car/app/model/Action.Builder#setTitle(java.lang.CharSequence)`, or a icon `https://developer.android.com/reference/androidx/car/app/model/Action` as set via `https://developer.android.com/reference/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)
public @NonNull RoutePreviewNavigationTemplate.Builder [setHeader](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setHeader(androidx.car.app.model.Header))(@NonNull Header header)
```

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

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

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

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

Sets the `https://developer.android.com/reference/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/androidx/car/app/model/Action#APP_ICON()` and `https://developer.android.com/reference/androidx/car/app/model/Action#BACK()` as a header `https://developer.android.com/reference/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)

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

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

Sets an `https://developer.android.com/reference/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/androidx/car/app/model/ItemList` should be smaller or equal than the limit provided by `https://developer.android.com/reference/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/androidx/car/app/model/OnClickListener` set. Each `https://developer.android.com/reference/androidx/car/app/model/Row` can add up to 2 lines of texts via `https://developer.android.com/reference/androidx/car/app/model/Row.Builder#addText(java.lang.CharSequence)` and cannot contain a `https://developer.android.com/reference/androidx/car/app/model/Toggle`.

Images of type `https://developer.android.com/reference/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/androidx/car/app/model/DistanceSpan` or a `https://developer.android.com/reference/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/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)

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

> [!CAUTION]
> **This method 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/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)
public @NonNull RoutePreviewNavigationTemplate.Builder [setMapActionStrip](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setMapActionStrip(androidx.car.app.model.ActionStrip))(@NonNull ActionStrip actionStrip)
```

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

Sets an `https://developer.android.com/reference/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/androidx/car/app/model/Action#PAN()` button in this `https://developer.android.com/reference/androidx/car/app/model/ActionStrip`, the app will not receive the user input for panning gestures from `https://developer.android.com/reference/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/androidx/car/app/model/Action`s in its map `https://developer.android.com/reference/androidx/car/app/model/ActionStrip`. Only `https://developer.android.com/reference/androidx/car/app/model/Action`s with icons set via `https://developer.android.com/reference/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)

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

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

Sets the `https://developer.android.com/reference/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/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)
public @NonNull RoutePreviewNavigationTemplate.Builder [setPanModeListener](https://developer.android.com/reference/androidx/car/app/navigation/model/RoutePreviewNavigationTemplate.Builder#setPanModeListener(androidx.car.app.navigation.model.PanModeListener))(@NonNull PanModeListener panModeListener)
```

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

Sets a `https://developer.android.com/reference/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/androidx/car/app/model/Action#PAN()` button in the map `https://developer.android.com/reference/androidx/car/app/model/ActionStrip`, the app will not receive the user input for panning gestures from `https://developer.android.com/reference/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)

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

> [!CAUTION]
> **This method is deprecated.**   
>
> use `https://developer.android.com/reference/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/androidx/car/app/model/DistanceSpan`s and `https://developer.android.com/reference/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/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)

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

> [!CAUTION]
> **This method is deprecated.**   
>
> use `https://developer.android.com/reference/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/androidx/car/app/model/DistanceSpan`s and `https://developer.android.com/reference/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/androidx/car/app/model/CarText` |   |