/** * Show this SnackBar. It will auto attach to the activity's root view. * @param activity */ public void show(Activity activity){ show((ViewGroup)activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT)); }
/** * Show this SnackBar. It will auto attach to the parent view. * @param parent Must be {@linke android.widget.FrameLayout} or {@link android.widget.RelativeLayout} */ public void show(ViewGroup parent){ if(mState == STATE_SHOWING || mState == STATE_DISMISSING) return; if(getParent() != parent) { if(getParent() != null) ((ViewGroup) getParent()).removeView(this); parent.addView(this); } show(); }
case R.id.snackbar_bt_mobile_single: mSnackBar.applyStyle(R.style.SnackBarSingleLine); mSnackBar.show(); break; case R.id.snackbar_bt_mobile_multi: mSnackBar.applyStyle(R.style.SnackBarMultiLine); mSnackBar.show(); break; case R.id.snackbar_bt_tablet_single: .actionText("CLOSE") .duration(0) .show(); break; case R.id.snackbar_bt_tablet_multi: .actionText(null) .duration(5000) .show(); break;
public void showSnackBar(String message){ SnackBar.make(this).actionText(message).duration(Snackbar.LENGTH_SHORT).show(); }