我正在为Android使用SweetAlert对话框。

https://github.com/pedant/sweet-alert-dialog

在成功对话框中,我想移至“确定”按钮并更改其样式。请说明如何删除“确定”按钮。

我在按钮单击时调用方法

new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
    .setTitleText("Good job!")
    .setContentText("You clicked the button!")
    .show();

最佳答案

您可以使用简单策略从甜蜜警报中访问按钮

SweetAlertDialog alertDialog = new SweetAlertDialog(MainActivity.this,SweetAlertDialog.SUCCESS_TYPE);
alertDialog.setTitleText("Good job!");
alertDialog.setContentText("You clicked the button!");
alertDialog.show();

Button btn = (Button) alertDialog.findViewById(R.id.confirm_button);
btn.setBackgroundColor(ContextCompat.getColor(UserSignupActivity.this,R.color.colorPrimary));


访问后,您可以设置样式,也可以根据需要隐藏按钮。

07-24 09:46
查看更多