public class Toaster extends Object
Toast class and its API to provide simpler usage when showing toast messages.
A simple message text can be shown via showToast(Context, CharSequence).| Modifier and Type | Class and Description |
|---|---|
static interface |
Toaster.Duration
Defines an annotation for determining set of allowed durations for
showToast(...)
methods. |
| Constructor and Description |
|---|
Toaster() |
| Modifier and Type | Method and Description |
|---|---|
static void |
showToast(Context context,
CharSequence text)
Same as
showToast(Context, CharSequence, int) with Toast.LENGTH_SHORT
duration flag. |
static void |
showToast(Context context,
CharSequence text,
int duration)
Shows a default
Toast with the formatted text. |
static void |
showToast(Context context,
int resId)
Same as
showToast(Context, int, int) with Toast.LENGTH_SHORT
duration flag. |
static void |
showToast(Context context,
int duration,
int resId)
Shows a default
Toast with the formatted text obtained from an application
resources by the specified resId. |
static void |
showToast(Context context,
int duration,
int resId,
Object... args)
Like
showToast(Context, int, String, Object...), but the specified
text will be formatted by the given args during of the obtaining process
from an application resources. |
static void |
showToast(Context context,
int duration,
String text,
Object... args)
Same as
showToast(Context, CharSequence, int) where the given args
will be used to format the specified text |
public static void showToast(@NonNull Context context, @StringRes int resId)
showToast(Context, int, int) with Toast.LENGTH_SHORT
duration flag.public static void showToast(@NonNull Context context, int duration, @StringRes int resId)
Toast with the formatted text obtained from an application
resources by the specified resId.context - Context to use to show the toast.duration - The flag to determine, how long should be toast visible. One of the
Toast.LENGTH_SHORT or Toast.LENGTH_LONG.resId - The resource id of the desired text to display in the toast.public static void showToast(@NonNull Context context, int duration, @StringRes int resId, @Nullable Object... args)
showToast(Context, int, String, Object...), but the specified
text will be formatted by the given args during of the obtaining process
from an application resources. See Resources.getString(int, Object...)
for more info.public static void showToast(@NonNull Context context, int duration, @NonNull String text, @Nullable Object... args)
showToast(Context, CharSequence, int) where the given args
will be used to format the specified textargs - The variable arguments to format the specified text.public static void showToast(@NonNull Context context, @NonNull CharSequence text)
showToast(Context, CharSequence, int) with Toast.LENGTH_SHORT
duration flag.public static void showToast(@NonNull Context context, @NonNull CharSequence text, int duration)
Toast with the formatted text.context - Context to use to show the toast.text - The desired text to display in the toast.duration - The flag to determine, how long should be toast visible. One of the
Toast.LENGTH_SHORT or Toast.LENGTH_LONG.