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

*** ** * ** ***


```
class TelephoneKeypadTemplate.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder#Builder(androidx.car.app.dialer.TelephoneKeypadTemplate)(template: https://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadTemplate)` Create a Builder for a `https://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadTemplate` with values from the given template. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder#Builder(androidx.car.app.model.Action,androidx.car.app.dialer.TelephoneKeypadTemplate.PhoneNumberChangeListener)( primaryAction: https://developer.android.com/reference/kotlin/androidx/car/app/model/Action, numberChangeListener: https://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadTemplate.PhoneNumberChangeListener )` Creates a builder for a `https://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadTemplate`. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder#addKeySecondaryText(int,androidx.car.app.model.CarText)(key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, secondaryText: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText)` Sets the secondary text underneath the numbers/symbols of the keypad, overwriting any text that already exists for the given `key`. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadTemplate` | `https://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder#build()()` Builds a `https://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadTemplate` |
| `https://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder#setHeader(androidx.car.app.model.Header)(header: https://developer.android.com/reference/kotlin/androidx/car/app/model/Header?)` Sets the header to show in the template. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder#setKeySecondaryTexts(java.util.Map<java.lang.Integer,androidx.car.app.model.CarText>)(secondaryTexts: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!, https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText!>)` 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://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder#setPhoneNumber(java.lang.String)(phoneNumber: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` Sets the phone number to show in the dialer which can be edited before calling. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadTemplate.Builder#setTelephoneKeypadCallback(androidx.car.app.dialer.TelephoneKeypadCallback)(callback: https://developer.android.com/reference/kotlin/androidx/car/app/dialer/TelephoneKeypadCallback?)` 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)

```
Builder(template: TelephoneKeypadTemplate)
```

Create a Builder for a `https://developer.android.com/reference/kotlin/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)

```
Builder(
    primaryAction: Action,
    numberChangeListener: TelephoneKeypadTemplate.PhoneNumberChangeListener
)
```

Creates a builder for a `https://developer.android.com/reference/kotlin/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/kotlin/androidx/car/app/model/Action.Builder#setOnClickListener(androidx.car.app.model.OnClickListener)` does not provide the fully dialed phone number.

## Public functions

### addKeySecondaryText

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

```
@CanIgnoreReturnValue
fun addKeySecondaryText(key: Int, secondaryText: CarText): TelephoneKeypadTemplate.Builder
```

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/kotlin/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)

```
fun build(): TelephoneKeypadTemplate
```

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

### setHeader

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

```
@CanIgnoreReturnValue
fun setHeader(header: Header?): TelephoneKeypadTemplate.Builder
```

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
fun setKeySecondaryTexts(secondaryTexts: (Mutable)Map<Int!, CarText!>): TelephoneKeypadTemplate.Builder
```

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/kotlin/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
fun setPhoneNumber(phoneNumber: String?): TelephoneKeypadTemplate.Builder
```

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
fun setTelephoneKeypadCallback(callback: TelephoneKeypadCallback?): TelephoneKeypadTemplate.Builder
```

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