public class Snackbar
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Snackbar.Gravity
Constant values for defining the placement of the
Snackbar within its container. |
| Modifier and Type | Field and Description |
|---|---|
static int |
LENGTH_INFINITE
Shows the text notification for an infinite period of time.
|
static int |
LENGTH_LONG
Shows the text notification for a long period of time.
|
static int |
LENGTH_SHORT
Shows the text notification for a short period of time.
|
| Modifier and Type | Method and Description |
|---|---|
void |
hide()
Hides the
Snackbar if it is currently showing; otherwise, does nothing. |
Snackbar |
setAction(java.lang.CharSequence action,
int color,
android.view.View.OnClickListener listener)
Sets the action button text and text color, and the botton's click event listener.
|
Snackbar |
setAction(int resId,
int color,
android.view.View.OnClickListener listener)
Sets the action button text and text color, and the botton's click event listener.
|
Snackbar |
setActions(int resId1,
int color1,
android.view.View.OnClickListener listener1,
int resId2,
int color2,
android.view.View.OnClickListener listener2)
Sets the text, text color, and the click event listeners for the two action buttons.
|
Snackbar |
setDuration(int duration)
Sets how long to show the text notification for.
|
Snackbar |
setGravity(Snackbar.Gravity gravity)
Sets the placement of the
Snackbar within its container. |
Snackbar |
setText(java.lang.CharSequence s)
Sets the string value of the
Snackbar. |
Snackbar |
setText(int resId)
Sets the string value of the
Snackbar. |
Snackbar |
setTextColor(int color)
Sets the text color of the string to be displayed.
|
void |
show()
Shows the
Snackbar. |
static Snackbar |
with(android.app.Activity activity)
Creates a
Snackbar with the given Activity as its container. |
public static final int LENGTH_SHORT
{#setDuration(int)},
Constant Field Valuespublic static final int LENGTH_LONG
{#setDuration(int)},
Constant Field Valuespublic static final int LENGTH_INFINITE
public Snackbar setDuration(int duration)
duration - The duration to show the text notification for.Snackbar object.#LENGTH_SHORT},
#LENGTH_LONG}public Snackbar setGravity(Snackbar.Gravity gravity)
Snackbar within its container.gravity - The placement, either Snackbar.Gravity.TOP or Snackbar.Gravity.BOTTOM.Snackbar object.Gravity#TOP},
Gravity#BOTTOM}public Snackbar setText(int resId)
Snackbar.resId - The string resource ID to set.Snackbar object.public Snackbar setText(java.lang.CharSequence s)
Snackbar.s - The string value to set.Snackbar object.public Snackbar setTextColor(int color)
color - The text color of the string to be displayed.Snackbar object.public Snackbar setAction(int resId, int color, android.view.View.OnClickListener listener)
resId - The action button text resource ID.color - The action button text color.listener - The action button click event listener.Snackbar object.public Snackbar setAction(java.lang.CharSequence action, int color, android.view.View.OnClickListener listener)
action - The action button text.color - The action button text color.listener - The action button click event listener.Snackbar object.public Snackbar setActions(int resId1, int color1, android.view.View.OnClickListener listener1, int resId2, int color2, android.view.View.OnClickListener listener2)
resId1 - The text resource ID for the first action button.color1 - The text color for the first action button.listener1 - The click event listener for the first action button.resId2 - The text resource ID for the second action button.color2 - The text color for the second action button.listener2 - The click event listener for the second action button.Snackbar object.public void show()
Snackbar.public void hide()
Snackbar if it is currently showing; otherwise, does nothing.