Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

SuperActivityToast

John Persano edited this page Jul 22, 2013 · 22 revisions

SuperActivityToasts

Introduction

SuperActivityToasts are made to replace stock Android Toasts that are used in an Activity Context. SuperActivityToasts can NOT be used in a non-Activity Context.

Usage

SuperActivityToasts should be used wherever an Activity Context is available. SuperActivityToasts attach themselves to the Activity's content meaning that the SuperActivityToast will not linger from screen to screen. When the Activity's content gets destroyed the SuperActivityToast gets destroyed along with it, eliminating out of Context messages.

Features

  1. Customization options such as background color, font, text size, etc.
  2. Duration can be any millisecond value.
  3. Developers can choose between any animation.
  4. An Image can be displayed along with the SuperActivityToast.
  5. SuperActivityToasts can be reused instead of created again.
  6. SuperActivityToasts can have an OnClickListener attached to them.
  7. Touch to dismiss function.
  8. SuperActivityToasts are attached to the Activity's content, not the WindowManager.
  9. Four Types that include Toast, Button, Progress, and Progress Horizontal.

Examples

To create a simple SuperActivityToast developers can create a new object.

 SuperActivityToast mSuperActivityToast = new SuperActivityToast(this);  
 mSuperActivityToast.setDuration(SuperToastConstants.DURATION_LONG);  
 mSuperActivityToast.setText("Hello world!");  
 mSuperActivityToast.show();  

Developers can also use a static method.

 SuperActivityToast.createDarkSuperActivityToast(this, "Hello world!", SuperToastConstants.DURATION_LONG).show();  

To style a SuperActivityToast developers will have to create a new object.

 SuperActivityToast mSuperActivityToast = new SuperActivityToast(this, SuperToast.Type.TOAST);  
 mSuperActivityToast.setDuration(SuperToastConstants.DURATION_LONG);  
 mSuperActivityToast.setShowAnimation(mShowAnimation);  
 mSuperActivityToast.setDismissAnimation(mDismissAnimation);  
 mSuperActivityToast.setBackgroundResource(SuperToastConstants.BACKGROUND_BLUETRANSLUCENT);  
 mSuperActivityToast.setTextColor(Color.WHITE);  
 mSuperActivityToast.setTextSize(SuperToastConstants.TEXTSIZE_MEDIUM);  
 mSuperActivityToast.setIconResource(R.drawable.icon);  
 mSuperActivityToast.setIconPosition(SuperActivityToast.IconPosition.LEFT);  
 mSuperActivityToast.setTypeface(mSuperActivityToast.loadRobotoTypeface(SuperToastConstants.FONT_ROBOTO_LIGHT));  
 mSuperActivityToast.setText("Hello world!");  
 mSuperActivityToast.setTouchToDismiss(true);  
 mSuperActivityToast.show();  
Clone this wiki locally