Skip to content


Anatoliy Shuba edited this page Mar 23, 2014 · 15 revisions


##Introduction SuperCardToasts are made to augment the stock Android Toast class. The idea for this SuperToast came from Benjamin Weiss's Crouton library.


SuperCardToasts should be used wherever an Activity context is available.
SuperCardToasts can NOT be used in a non-Activity context.


SuperCardToasts offer a new way of showing toast messages.
SuperCardToasts attach themselves to the activity's content and will not linger from activity to activity.
SuperCardToasts can have buttons, progressbars, and icons.


  1. Customization options such as background color, font, text size, animations etc.
  2. SuperCardToasts are stackable.
  3. Swipe/touch to dismiss options.
  4. Does not hide any of the activity's existing content.
  5. Duration can be any millisecond value.
  6. Orientation change support


You must place this layout in the top of your activity's layout. This is where SuperCardToasts will be attached. If you are using fragments you should put this at the top of your host activity's layout. Try setting the background color of this layout to match your ActionBar.

    android:orientation="vertical" />

A simple SuperCardToast displaying the text "Hello world!".
SuperCardToast.create(Activity.this, "Hello world!", SuperToast.Duration.LONG).show();

A blue styled SuperCardToast displaying the text "Hello world!" with a different animation.
SuperCardToast.create(Playground.this, "Hello world!", SuperToast.Duration.SHORT,
    Style.getStyle(Style.BLUE, SuperToast.Animations.FLYIN)).show();

A SuperCardToast displaying the text "Hello world!" with a different background, text color, and will dismiss if the user swipes it.
SuperCardToast superCardToast = new SuperCardToast(Activity.this);
superCardToast.setText("Hello world!");

An indeterminate SuperCardToast displaying the text "Hello world!" with an indeterminate progressbar.
SuperCardToast superCardToast = new SuperCardToast(Activity.this, SuperToast.Type.PROGRESS);
superCardToast.setText("Hello world!");

A SuperCardToast displaying the text "Hello world!" with a button
SuperCardToast superCardToast = new SuperCardToast(Activity.this, SuperToast.Type.BUTTON));
superCardToast.setText("Some action performed.");
superCardToast.setButtonIcon(SuperToast.Icon.Dark.UNDO, "UNDO");

To use the button in BUTTON type SuperCardToasts, define an OnClickWrapper somewhere in your Activity.
The first parameter is a string tag unique to this OnClickWrapper, the second parameter is the OnClickListener.

OnClickWrapper onClickWrapper = new OnClickWrapper("supercardtoast", new SuperToast.OnClickListener() {

    public void onClick(View view, Parcelable token) {

        /** On click event */



Orientation change support

To have SuperCardToasts retain themselves on orientation change add this code to your Activity.


If you do not call SuperCardToast.onSaveState() you may have lingering SuperCardToasts when a new Activity is started on top of a showing SuperCardToast.

protected void onSaveInstanceState(Bundle outState) {



Also, add this restore method to the onCreate of your Activity if you are NOT using any OnClickWrappers/OnDismissWrapers.

SuperCardToast.onRestoreState(savedInstanceState, Activity.this);

If you ARE using any OnClickWrappers/OnDismissWrapers you must use the following code instead.
The Wrappers object helps to reattach any OnClickWrappers/OnDismissWrapers on orientation change so any OnClickWrappers/OnDismissWrapers used must be added to it.

Wrappers wrappers = new Wrappers();
SuperCardToast.onRestoreState(Activity.this, savedInstanceState, wrappers);
You can’t perform that action at this time.