避免连续点击吐司长时间不消失

来源:互联网 发布:mysql 语句 编辑:程序博客网 时间:2024/04/29 13:16

很简单,单例即可

public class ToastUtils
{
    private static Toast toast;
    public static void showToast(Context context,String str){
        if(toast==null){
            toast = toast.makeText(context, str, Toast.LENGTH_SHORT);
        }else {
            toast.cancel();
            toast=toast.makeText(context, str, Toast.LENGTH_SHORT);
        }
        toast.show();
    }
}

0 0