CarToast
public
final
class
CarToast
extends Object
java.lang.Object | |
↳ | com.google.android.libraries.car.app.CarToast |
A message to show to the user for a short period of time.
Summary
Constants | |
---|---|
int |
LENGTH_LONG
Show the Toast view for a long period of time. |
int |
LENGTH_SHORT
Show the Toast view for a short period of time. |
Public methods | |
---|---|
static
CarToast
|
makeText(CarContext carContext, int textResId, int duration)
Creates and sets the text and duration for the toast view. |
static
CarToast
|
makeText(CarContext carContext, CharSequence text, int duration)
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(CharSequence text)
Sets the text for the toast. |
void
|
setText(int textResId)
Sets the text for the toast. |
void
|
show()
Shows the toast with the specified text for the specified duration. |
Inherited methods | |
---|---|
Constants
LENGTH_LONG
public static final int LENGTH_LONG
Show the Toast view for a long period of time.
See also:
Constant Value: 1 (0x00000001)
LENGTH_SHORT
public static final int LENGTH_SHORT
Show the Toast view for a short period of time. This is the default duration.
See also:
Constant Value: 0 (0x00000000)
Public methods
makeText
public static CarToast makeText (CarContext carContext, int textResId, int duration)
Creates and sets the text and duration for the toast view.
Parameters | |
---|---|
carContext |
CarContext |
textResId |
int : the resource id for the text to show. If the textResId is 0, the text
will be set to empty. |
duration |
int : how long to display the message. Either LENGTH_SHORT or LENGTH_LONG |
Returns | |
---|---|
CarToast |
Throws | |
---|---|
NullPointerException |
if carContext is null .
|
makeText
public static CarToast makeText (CarContext carContext, CharSequence text, int duration)
Creates and sets the text and duration for the toast view.
Parameters | |
---|---|
carContext |
CarContext |
text |
CharSequence : the text to show |
duration |
int : how long to display the message. Either LENGTH_SHORT or LENGTH_LONG |
Returns | |
---|---|
CarToast |
Throws | |
---|---|
NullPointerException |
if either the carContext or the text are null .
|
setDuration
public void setDuration (int duration)
Sets how long to show the toast for.
Parameters | |
---|---|
duration |
int : how long to display the message. Either LENGTH_SHORT or LENGTH_LONG
|
setText
public void setText (CharSequence text)
Sets the text for the toast.
Parameters | |
---|---|
text |
CharSequence |
Throws | |
---|---|
NullPointerException |
if text is null .
|
setText
public void setText (int textResId)
Sets the text for the toast.
Parameters | |
---|---|
textResId |
int : the resource id for the text. If the textResId is 0, the text will be
set to empty.
|
show
public void show ()
Shows the toast with the specified text for the specified duration.
Throws | |
---|---|
HostException |
if the remote call fails. |