android开发Tost工具类管理(一)

Tost工具类管理:

 1 package com.gzcivil.utils;
 2 
 3 import android.content.Context;
 4 import android.widget.Toast;
 5 
 6 /**
 7  * 
 8  * @author LiJinlun date 2016-01-10
 9  */
10 public class MyToast {
11     private static Toast mToast = null;
12 
13     /* 
14      * 一个Activity 可以显示多次 但是如果mToast已经显示了则只需改变内容,无须等待上次隐藏再次显示
15      */
16     public static void showToast(Context mContext, String text, int duration) {
17 
18         if (mToast != null)
19             mToast.setText(text);
20         else
21             mToast = Toast.makeText(mContext, text, duration);
22         mToast.show();
23     }
24 
25     public static void showToast(Context mContext, int aResId, int duration) {
26 
27         if (mToast != null)
28             mToast.setText(aResId);
29         else
30             mToast = Toast.makeText(mContext, aResId, duration);
31         mToast.show();
32     }
33 }
原文地址:https://www.cnblogs.com/lijinlun0825/p/5174728.html