转自:http://blog.youkuaiyun.com/guolin_blog/article/details/51336415
public static void show(Context context, CharSequence text, int duration) {
//Toast.makeText(context, text, duration).show();
if (mToast == null) {
mToast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
} else {
mToast.setText(text);
mToast.setDuration(Toast.LENGTH_SHORT);
}
mToast.show();
}
//退出activity时如果需要Toast立即消失的话
public static void cancelToast() {
if (mToast != null) {
mToast.cancel();
}
}