点击后立刻反映Toast

来源:互联网 发布:北京淘宝摄影 编辑:程序博客网 时间:2024/06/10 06:24


public class ToastUtil {    private static Toast mToast;    public static void showToast(Context context,String str){        if(mToast==null){            mToast=new Toast(context);            View view=mToast.makeText(context,"",Toast.LENGTH_SHORT).getView();            mToast.setView(view);            mToast.setText(str);            mToast.setDuration(Toast.LENGTH_SHORT);            mToast.show();        }else{            mToast.setText(str);            mToast.show();        }    }}


0 0