正确使用toast

        用户操作时候可能出现多次重复点击一个按钮的现象,然后toast的就断弹出,甚至当我们进行其他操作的时候,本应弹出新的toast,但是还是显示之前还未显示完成的toast,所以有必要正确的使用toast,我的做法是新建一个类,把toast进行封装:

public class toast {
    private static Toast toast;

    public static void showToast(Context context,String content){
        if(null==toast)
            toast=Toast.makeText(context,content,Toast.LENGTH_LONG);
        else
            toast.setText(content);
        toast.show();
    }

}

猜你喜欢

转载自2723364262.iteye.com/blog/2314405