Toast 多按不重叠

将Toast封装成一个单独的类

public class ToastUtil {

    private static Toast toast;

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


猜你喜欢

转载自blog.csdn.net/qq_35820350/article/details/79217112