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