/** * Set the text that the ActionButton is to display. * @param id If 0, then the ActionButton will be hidden. * @return This SnackBar for chaining methods. */ public SnackBar actionText(int id){ if(id == 0) return actionText(null); return actionText(getContext().getResources().getString(id)); }
actionTextAppearance = a.getResourceId(attr, 0); else if(attr == R.styleable.SnackBar_sb_actionText) actionText(a.getString(attr)); else if(attr == R.styleable.SnackBar_sb_actionRipple) actionRipple(a.getResourceId(attr, 0));
mSnackBar.applyStyle(R.style.Material_Widget_SnackBar_Tablet); mSnackBar.text("This is single-line snackbar.") .actionText("CLOSE") .duration(0) .show(); mSnackBar.applyStyle(R.style.Material_Widget_SnackBar_Tablet_MultiLine); mSnackBar.text("This is multi-line snackbar.\nIt will auto-close after 5s.") .actionText(null) .duration(5000) .show();
public void showSnackBar(String message){ SnackBar.make(this).actionText(message).duration(Snackbar.LENGTH_SHORT).show(); }