# TtsSpan.Builder

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

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/text/style/TtsSpan.Builder "View this page in Java")  

```
open class Builder<C : TtsSpan.Builder<*>!>
```

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

|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Direct Subclasses [TtsSpan.SemioticClassBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.SemioticClassBuilder) |--------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------| | [TtsSpan.SemioticClassBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.SemioticClassBuilder) | A builder for TtsSpans, has setters for morphosyntactic features. | |

|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Indirect Subclasses [TtsSpan.CardinalBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.CardinalBuilder),[TtsSpan.DateBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.DateBuilder),[TtsSpan.DecimalBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.DecimalBuilder),[TtsSpan.DigitsBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.DigitsBuilder),[TtsSpan.DurationBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.DurationBuilder),[TtsSpan.ElectronicBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.ElectronicBuilder),[TtsSpan.FractionBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.FractionBuilder),[TtsSpan.MeasureBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.MeasureBuilder),[TtsSpan.MoneyBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.MoneyBuilder),[TtsSpan.OrdinalBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.OrdinalBuilder),[TtsSpan.TelephoneBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.TelephoneBuilder),[TtsSpan.TextBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.TextBuilder), and 2 others. |--------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------| | [TtsSpan.CardinalBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.CardinalBuilder)     | A builder for TtsSpans of type[TYPE_CARDINAL](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan#TYPE_CARDINAL:kotlin.String).     | | [TtsSpan.DateBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.DateBuilder)             | A builder for TtsSpans of type[TYPE_DATE](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan#TYPE_DATE:kotlin.String).             | | [TtsSpan.DecimalBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.DecimalBuilder)       | A builder for TtsSpans of type[TYPE_DECIMAL](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan#TYPE_DECIMAL:kotlin.String).       | | [TtsSpan.DigitsBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.DigitsBuilder)         | A builder for TtsSpans of type[TYPE_DIGITS](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan#TYPE_DIGITS:kotlin.String).         | | [TtsSpan.DurationBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.DurationBuilder)     | A builder for TtsSpans of type[TYPE_DURATION](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan#TYPE_DURATION:kotlin.String).     | | [TtsSpan.ElectronicBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.ElectronicBuilder) | A builder for TtsSpans of type[TYPE_ELECTRONIC](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan#TYPE_ELECTRONIC:kotlin.String). | | [TtsSpan.FractionBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.FractionBuilder)     | A builder for TtsSpans of type[TYPE_FRACTION](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan#TYPE_FRACTION:kotlin.String).     | | [TtsSpan.MeasureBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.MeasureBuilder)       | A builder for TtsSpans of type[TYPE_MEASURE](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan#TYPE_MEASURE:kotlin.String).       | | [TtsSpan.MoneyBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.MoneyBuilder)           | A builder for TtsSpans of type[TYPE_MONEY](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan#TYPE_MONEY:kotlin.String).           | | [TtsSpan.OrdinalBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.OrdinalBuilder)       | A builder for TtsSpans of type[TYPE_ORDINAL](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan#TYPE_ORDINAL:kotlin.String).       | | [TtsSpan.TelephoneBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.TelephoneBuilder)   | A builder for TtsSpans of type[TYPE_TELEPHONE](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan#TYPE_TELEPHONE:kotlin.String).   | | [TtsSpan.TextBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.TextBuilder)             | A builder for TtsSpans of type[TYPE_TEXT](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan#TYPE_TEXT:kotlin.String).             | | [TtsSpan.TimeBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.TimeBuilder)             | A builder for TtsSpans of type[TYPE_TIME](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan#TYPE_TIME:kotlin.String).             | | [TtsSpan.VerbatimBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.VerbatimBuilder)     | A builder for TtsSpans of type[TYPE_VERBATIM](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan#TYPE_VERBATIM:kotlin.String).     | |

A simple builder for TtsSpans. This builder can be used directly, but the more specific subclasses of this builder like[TtsSpan.TextBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.TextBuilder)and[TtsSpan.CardinalBuilder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.CardinalBuilder)are likely more useful. This class uses generics so methods from this class can return instances of its child classes, resulting in a fluent API (CRTP pattern).

## Summary

|                                                                                                     Public constructors                                                                                                      ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.Builder#Builder(kotlin.String))`(`type:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` <br /> |

|                                                                                                                                                                                                                                   Public methods                                                                                                                                                                                                                                    ||
|-------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[TtsSpan](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan)! | [build](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.Builder#build())`()` Returns a TtsSpan built from the parameters set by the setter methods.                                                                                                                                                                                                            |
| openC                                                                                     | [setIntArgument](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.Builder#setIntArgument(kotlin.String,%20kotlin.Int))`(`arg:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `value:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets an argument to an int value.                   |
| openC                                                                                     | [setLongArgument](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.Builder#setLongArgument(kotlin.String,%20kotlin.Long))`(`arg:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `value:` `[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)`)` Sets an argument to a long value.              |
| openC                                                                                     | [setStringArgument](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan.Builder#setStringArgument(kotlin.String,%20kotlin.String))`(`arg:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`, `value:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Sets an argument to a string value. |

## Public constructors

### Builder

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

```
Builder(type: String!)
```

## Public methods

### build

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

```
open fun build(): TtsSpan!
```

Returns a TtsSpan built from the parameters set by the setter methods.

|                                                                 Return                                                                  ||
|---------------------------------------------------------------------------------------|--------------------------------------------------|
| [TtsSpan](https://developer.android.com/reference/kotlin/android/text/style/TtsSpan)! | A TtsSpan built with parameters of this builder. |

### setIntArgument

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

```
open fun setIntArgument(
    arg: String!, 
    value: Int
): C
```

Sets an argument to an int value.

|                                                          Parameters                                                          ||
|---------|---------------------------------------------------------------------------------------------------------------------|
| `arg`   | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!:The argument name.                |
| `value` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The value the argument should be set to. |

### setLongArgument

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

```
open fun setLongArgument(
    arg: String!, 
    value: Long
): C
```

Sets an argument to a long value.

|                                                           Parameters                                                           ||
|---------|-----------------------------------------------------------------------------------------------------------------------|
| `arg`   | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!:The argument name.                  |
| `value` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html):The value the argument should be set to. |

### setStringArgument

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

```
open fun setStringArgument(
    arg: String!, 
    value: String!
): C
```

Sets an argument to a string value.

|                                                             Parameters                                                              ||
|---------|----------------------------------------------------------------------------------------------------------------------------|
| `arg`   | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!:The argument name.                       |
| `value` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!:The value the argument should be set to. |

|      Return       ||
|---|----------------|
| C | This instance. |