问题描述:
当连续点击按钮后,Toast会连续显示,直到响应完所有点击,这不是我们想要的效果。
我们想要的是,每次点击后取消上一次的toast,立即响应这一次的点击
编写一个方法如下:只需要在显示之前取消当前的toast,然后再显示即可!!!
private static Toast toast = null;
static void toastShow(Context context, String text, int duration) {
if (null != toast)
toast.cancel();
toast = Toast.makeText(context, text, duration);
toast.show();
}