CarText.Builder

public static final class CarText.Builder
extends Object

java.lang.Object
   ↳ androidx.car.app.model.CarText.Builder


A builder of CarText.

Summary

Public constructors

Builder(CharSequence text)

Returns a new instance of a CarText.Builder.

Public methods

CarText.Builder addVariant(CharSequence text)

Adds a text variant for the CarText instance.

CarText build()

Constructs the CarText defined by this builder.

Inherited methods

Public constructors

Builder

public Builder (CharSequence text)

Returns a new instance of a CarText.Builder.

Only CarSpan type spans are allowed in a CarText, other spans will be removed from the provided CharSequence.

Parameters
text CharSequence: the first variant of the text to use. This represents the app's preferred text variant. Other alternatives can be supplied with addVariant(CharSequence).

Throws
NullPointerException if the text is null

Public methods

addVariant

public CarText.Builder addVariant (CharSequence text)

Adds a text variant for the CarText instance.

Only CarSpan type spans are allowed in a CarText, other spans will be removed from the provided CharSequence.

The text variants should be added in order of preference, from most to least preferred (for instance, from longest to shortest). If the text provided via Builder(CharSequence) does not fit in the screen, the host will display the first variant that fits in the screen.

Parameters
text CharSequence

Returns
CarText.Builder

Throws
NullPointerException if the text is null

build

public CarText build ()

Constructs the CarText defined by this builder.

Returns
CarText