# ViewTranslationResponse.Builder

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/android/view/translation/ViewTranslationResponse.Builder "View this page in Java")  

```
class Builder
```

|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                                       ||
| ↳ | [android.view.translation.ViewTranslationResponse.Builder](https://developer.android.com/reference/kotlin/android/view/translation/ViewTranslationResponse.Builder#) |

A builder for [ViewTranslationResponse](https://developer.android.com/reference/kotlin/android/view/translation/ViewTranslationResponse)

## Summary

|                                                                                                                                              Public constructors                                                                                                                                              ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/view/translation/ViewTranslationResponse.Builder#Builder(android.view.autofill.AutofillId))`(`autofillId:` `[AutofillId](https://developer.android.com/reference/kotlin/android/view/autofill/AutofillId.html#)`)` Creates a new Builder. |

|                                                                                                                                                                                                                                                                                                                                                                          Public methods                                                                                                                                                                                                                                                                                                                                                                          ||
|----------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ViewTranslationResponse](https://developer.android.com/reference/kotlin/android/view/translation/ViewTranslationResponse)                   | [build](https://developer.android.com/reference/kotlin/android/view/translation/ViewTranslationResponse.Builder#build())`()` Builds the instance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [ViewTranslationResponse.Builder](https://developer.android.com/reference/kotlin/android/view/translation/ViewTranslationResponse.Builder#)! | [setValue](https://developer.android.com/reference/kotlin/android/view/translation/ViewTranslationResponse.Builder#setValue(kotlin.String,%20android.view.translation.TranslationResponseValue))`(`key:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `value:` `[TranslationResponseValue](https://developer.android.com/reference/kotlin/android/view/translation/TranslationResponseValue)!`)` Sets the corresponding [TranslationResponseValue](https://developer.android.com/reference/kotlin/android/view/translation/TranslationResponseValue) for the provided key. |

## Public constructors

### Builder

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Builder(autofillId: AutofillId)
```

Creates a new Builder.

|                                                                                                                                             Parameters                                                                                                                                             ||
|--------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `autofillId` | [AutofillId](https://developer.android.com/reference/kotlin/android/view/autofill/AutofillId.html#): The [AutofillId](https://developer.android.com/reference/kotlin/android/view/autofill/AutofillId.html#) of the view associated with this response. This value cannot be `null`. |

## Public methods

### build

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun build(): ViewTranslationResponse
```

Builds the instance. This builder should not be touched after calling this!

|                                                                          Return                                                                          ||
|----------------------------------------------------------------------------------------------------------------------------|------------------------------|
| [ViewTranslationResponse](https://developer.android.com/reference/kotlin/android/view/translation/ViewTranslationResponse) | This value cannot be `null`. |

### setValue

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setValue(
    key: String!, 
    value: TranslationResponseValue!
): ViewTranslationResponse.Builder!
```

Sets the corresponding [TranslationResponseValue](https://developer.android.com/reference/kotlin/android/view/translation/TranslationResponseValue) for the provided key.

|                                                                                               Parameters                                                                                               ||
|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `key`   | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: The key for this translation response value.                                                               |
| `value` | [TranslationResponseValue](https://developer.android.com/reference/kotlin/android/view/translation/TranslationResponseValue)!: the translation response value holding the translated content. |

|                                                                           Return                                                                            ||
|----------------------------------------------------------------------------------------------------------------------------------------------|---------------|
| [ViewTranslationResponse.Builder](https://developer.android.com/reference/kotlin/android/view/translation/ViewTranslationResponse.Builder#)! | this builder. |