CarToast
public final class CarToast
A message to show to the user for a short period of time.
Summary
Constants |
|
|---|---|
static final int |
LENGTH_LONG = 1Show the Toast view for a long period of time. |
static final int |
LENGTH_SHORT = 0Show the Toast view for a short period of time. |
Public methods |
|
|---|---|
static @NonNull CarToast |
makeText(Creates and sets the text and duration for the toast view. |
static @NonNull CarToast |
makeText(Creates and sets the text and duration for the toast view. |
void |
setDuration(int duration)Sets how long to show the toast for. |
void |
setText(@NonNull CharSequence text)Sets the text for the toast. |
void |
Sets the text for the toast. |
void |
show()Shows the toast with the specified text for the specified duration. |
Constants
LENGTH_LONG
public static final int LENGTH_LONG = 1
Show the Toast view for a long period of time.
| See also | |
|---|---|
setDuration |
LENGTH_SHORT
public static final int LENGTH_SHORT = 0
Show the Toast view for a short period of time. This is the default duration.
| See also | |
|---|---|
setDuration |
Public methods
makeText
public static @NonNull CarToast makeText(
@NonNull CarContext carContext,
@NonNull CharSequence text,
int duration
)
Creates and sets the text and duration for the toast view.
| Parameters | |
|---|---|
@NonNull CarContext carContext |
the CarContext providing the service used to show the toast |
@NonNull CharSequence text |
the text to show |
int duration |
how long to display the message. Either |
| Throws | |
|---|---|
java.lang.NullPointerException |
if either the |
makeText
public static @NonNull CarToast makeText(
@NonNull CarContext carContext,
@StringRes int textResId,
int duration
)
Creates and sets the text and duration for the toast view.
| Parameters | |
|---|---|
@NonNull CarContext carContext |
the context used for string localization |
@StringRes int textResId |
the resource id for the text to show. If the |
int duration |
how long to display the message. Either |
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
setDuration
public void setDuration(int duration)
Sets how long to show the toast for.
| Parameters | |
|---|---|
int duration |
how long to display the message. Either |
setText
public void setText(@NonNull CharSequence text)
Sets the text for the toast.
| Throws | |
|---|---|
java.lang.NullPointerException |
if |
setText
public void setText(@StringRes int textResId)
Sets the text for the toast.
| Parameters | |
|---|---|
@StringRes int textResId |
the resource id for the text. If the |
show
public void show()
Shows the toast with the specified text for the specified duration.
| Throws | |
|---|---|
androidx.car.app.HostException |
if the remote call fails |