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

*** ** * ** ***


```
public final class TelephoneKeypadTemplate.Builder
```

<br />

*** ** * ** ***

A builder for `https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder#Builder(androidx.car.app.dialer.TelephoneKeypadTemplate)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate template)` Create a Builder for a `https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate` with values from the given template. |
| `https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder#Builder(androidx.car.app.model.Action,androidx.car.app.dialer.TelephoneKeypadTemplate.PhoneNumberChangeListener)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/Action primaryAction, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate.PhoneNumberChangeListener numberChangeListener )` Creates a builder for a `https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate`. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder#addKeySecondaryText(int,androidx.car.app.model.CarText)(int key, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/CarText secondaryText)` Sets the secondary text underneath the numbers/symbols of the keypad, overwriting any text that already exists for the given `key`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate` | `https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder#build()()` Builds a `https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder#setHeader(androidx.car.app.model.Header)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/Header header)` Sets the header to show in the template. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder#setKeySecondaryTexts(java.util.Map<java.lang.Integer,androidx.car.app.model.CarText>)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/java/lang/Integer.html, https://developer.android.com/reference/androidx/car/app/model/CarText> secondaryTexts)` Sets all the given button's `secondaryTexts`, overwriting existing values, but not clearing any existing values (eg. if KEY_ONE was already added and the map passed in only included TWO, the result would be both ONE and TWO). |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder#setPhoneNumber(java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/String.html phoneNumber)` Sets the phone number to show in the dialer which can be edited before calling. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder#setTelephoneKeypadCallback(androidx.car.app.dialer.TelephoneKeypadCallback)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadCallback callback)` Sets the callback for the keypad. |

## Public constructors

### Builder

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

```
public Builder(@NonNull TelephoneKeypadTemplate template)
```

Create a Builder for a `https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate` with values from the given template.

### Builder

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

```
public Builder(
    @NonNull Action primaryAction,
    @NonNull TelephoneKeypadTemplate.PhoneNumberChangeListener numberChangeListener
)
```

Creates a builder for a `https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate`.

`primaryAction` is usually the "call" button, but can be set arbitrarily by the app (eg. it can be a hangup button when the user is in a call). This action must include an icon,must not have text, and may define a custom color (subject to contrast requirements). This action is subject to the constraints defined in .

The app must keep track of the dialed phone number via `numberChangeListener` because the primary action's `https://developer.android.com/reference/androidx/car/app/model/Action.Builder#setOnClickListener(androidx.car.app.model.OnClickListener)` does not provide the fully dialed phone number.

## Public methods

### addKeySecondaryText

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

```
@CanIgnoreReturnValue
public @NonNull TelephoneKeypadTemplate.Builder addKeySecondaryText(int key, @NonNull CarText secondaryText)
```

Sets the secondary text underneath the numbers/symbols of the keypad, overwriting any text that already exists for the given `key`. Both icon and text is allowed (for example, showing a voicemail icon underneath the 1 key to denote that pressing and holding that key will automatically call voicemail). The `secondaryText` is subject to the constraints defined in .

Throws an `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` for any invalid keys.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder#setKeySecondaryTexts(java.util.Map<java.lang.Integer,androidx.car.app.model.CarText>)` | to mass set button secondary text |

### build

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

```
public @NonNull TelephoneKeypadTemplate build()
```

Builds a `https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate`

### setHeader

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

```
@CanIgnoreReturnValue
public @NonNull TelephoneKeypadTemplate.Builder setHeader(@Nullable Header header)
```

Sets the header to show in the template.

The start action of the header, if present, is subject to the constraints defined in .

### setKeySecondaryTexts

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

```
@CanIgnoreReturnValue
public @NonNull TelephoneKeypadTemplate.Builder setKeySecondaryTexts(@NonNull Map<Integer, CarText> secondaryTexts)
```

Sets all the given button's `secondaryTexts`, overwriting existing values, but not clearing any existing values (eg. if KEY_ONE was already added and the map passed in only included TWO, the result would be both ONE and TWO). Throws an `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` for any invalid keys.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder#addKeySecondaryText(int,androidx.car.app.model.CarText)` | to set individual buttons |

### setPhoneNumber

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

```
@CanIgnoreReturnValue
public @NonNull TelephoneKeypadTemplate.Builder setPhoneNumber(@Nullable String phoneNumber)
```

Sets the phone number to show in the dialer which can be edited before calling.

If a phone number is being edited in an existing instance of this template the value will be reset to the phone number in the new template.

### setTelephoneKeypadCallback

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

```
@CanIgnoreReturnValue
public @NonNull TelephoneKeypadTemplate.Builder setTelephoneKeypadCallback(@Nullable TelephoneKeypadCallback callback)
```

Sets the callback for the keypad. See `https://developer.android.com/reference/androidx/car/app/dialer/TelephoneKeypadCallback`.