public final class

CarText.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.car.app.model.CarText.Builder

Overview

A builder of CarText.

Summary

Constructors
publicBuilder(java.lang.CharSequence text)

Returns a new instance of a CarText.Builder.

Methods
public CarText.BuilderaddVariant(java.lang.CharSequence text)

Adds a text variant for the CarText instance.

public CarTextbuild()

Constructs the CarText defined by this builder.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder(java.lang.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 java.lang.CharSequence.

Parameters:

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

See also: CarText.Builder.addVariant(CharSequence)

Methods

public CarText.Builder addVariant(java.lang.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 java.lang.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 CarText.Builder.Builder(CharSequence) does not fit in the screen, the host will display the first variant that fits in the screen.

For instance, if the variant order is ["long string", "shorter", "short"], and the screen can fit 7 characters, "shorter" will be chosen. However, if the order is ["short", "shorter", "long string"], "short" will be chosen, because "short" fits within the 7 character limit.

public CarText build()

Constructs the CarText defined by this builder.