android,防止toast重复显示的方法

来源:互联网 发布:mac投影分辨率设置 编辑:程序博客网 时间:2024/05/29 08:58

最好是封装在一个方法里面

方法中做判断

private Toast mtoast;
private void showTextToast(String msg) {if (mtoast == null) {mtoast = Toast.makeText(getApplicationContext(), msg,Toast.LENGTH_SHORT);} else {mtoast.setText(msg);}mtoast.show();}

这样就只有一个toast对象

0 0