Android消除Toast延迟显示

    Toast可以用来显示音量改变或者保存更新消息,如果用户一直点击,Toast会排队一个一个的,直到消息队列全部显示完,这样的效果显然是不好的,下面来看解决方法

    Toast.makeText(activity, text, duration)每次会实例化一个Toast,所以
   

?
1
2
3
4
5
6
7
8
9
10
if (toast != null )
     {
         toast.setText(text);
         toast.setDuration(duration);
         toast.show();
     } else
     {
         toast = Toast.makeText(activity, text, duration);
         toast.show();
     }

你可能感兴趣的:(Android,项目实战)