智慧是宝石,如果用谦虚镶边,就会更加灿烂夺目。——高尔基

如果想要安卓的dialog点击按钮后默认不关闭弹框,可以这么写

1
2
3
4
5
6
7
8
9
10
11
AlertDialog.Builder builder = new AlertDialog.Builder(context);
AlertDialog alertDialog = builder.setPositiveButton("保存", null)
.setNegativeButton("收藏", (dialog, which) -> {
ToastUtils.shortToast("我还没做收藏功能!");
}).create();
alertDialog.show();
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(v1 -> {
RestVolleyDownload.DownloadResponse response = RestVolleyDownload.syncDownload(context, url, url.substring(url.lastIndexOf("/") + 1));
System.out.println(response);
ToastUtils.shortToast("保存成功");
});