Toast可以用来显示音量改变或者保存更新消息,如果用户一直点击,Toast会排队一个一个的,直到消息队列全部显示完,这样的效果显然是不好的,下面来看解决方法
Toast.makeText(activity, text, duration)每次会实例化一个Toast,所以
01 | if (toast != null ) |
02 | { |
03 | toast.setText(text); |
04 | toast.setDuration(duration); |
05 | toast.show(); |
06 | } else |
07 | { |
08 | toast = Toast.makeText(activity, text, duration); |
09 | toast.show(); |
10 | } |