解决Android 连续多次点击 Toast 重复显示

在这里我封装好了一个类
import android.content.Context;
import android.widget.Toast;

public class ToastUtil {
    private static Toast mToast;

    public static void ShowMsg(Context context, String msg,int duration) {
        if (mToast == null) {
            mToast = Toast.makeText(context, msg, duration);
        }else {
            mToast.setText(msg);
        }
        mToast.show();
    }
}
方法调用
ToastUtil.ShowMsg(this,"我被点击了",3);
//转载请保留 http://www.luofenming.com/show.aspx?id=ART2020092900001