android - 更改 Sweet alert 中的按钮样式

标签 android android-alertdialog sweetalert

我正在使用适用于 Android 的 SweetAlert Dialog。

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

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

我在点击按钮时调用方法

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

最佳答案

您可以使用简单的策略从sweet alert访问按钮

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));

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

关于android - 更改 Sweet alert 中的按钮样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45854694/

相关文章:

android - Android 中如何比较当前时间与第二天时间?

android - 在 Android TV 上收听 HDMI 插入和拔出事件

android - 如何在 TabLayout 中的选项卡之间添加边距?

android - 如何在 android 中以编程方式与 USSD 对话框交互

javascript - 更改警报中的图像大小

java - 将不同的图像放在 View /适配器中

android - 将 ArrayAdapter 与 AlertDialog 和 .setAdapter 结合使用

android - 进度对话框导致 "window leak"

javascript - 如何在 .js 文件中使用 sweetalert