F0RIS/sweet-alert-dialog

setCancelButtonBackgroundColor not working

Opened this issue · 5 comments

java.lang.ClassCastException: com.google.android.material.button.MaterialButtonBackgroundDrawable cannot be cast to android.graphics.drawable.StateListDrawable
        at cn.pedant.SweetAlert.ViewUtils.getDrawable(ViewUtils.java:11)
        at cn.pedant.SweetAlert.SweetAlertDialog.setButtonBackgroundColor(SweetAlertDialog.java:482)
        at cn.pedant.SweetAlert.SweetAlertDialog.setCancelButtonBackgroundColor(SweetAlertDialog.java:472)
        at cn.pedant.SweetAlert.SweetAlertDialog.onCreate(SweetAlertDialog.java:224)

did you get the solution?
I want to set a custom Yellow color, but it sets Dark Grey color.
.setConfirmButtonBackgroundColor(R.color.colorAccent)

Me too.I want to change button background color,but it not show.

SweetAlertDialog sDialog = new SweetAlertDialog(UserComplaintRegistration.this,SweetAlertDialog.WARNING_TYPE);
sDialog.setTitleText("a"));
sDialog.setCancelable(false);
sDialog.setConfirmButtonBackgroundColor(Color.parseColor("#fffc3061"));

or

sDialog.setConfirmButtonBackgroundColor(ContextCompat.getColor(context,R.color.colorPrimary));

this worked for me

Caused by: java.lang.ClassCastException: android.graphics.drawable.RippleDrawable cannot be cast to android.graphics.drawable.StateListDrawable

Please resolve this issue. Anyone got solution for this error?

// alert_dialog

<Button
....

to

<androidx.appcompat.widget.AppCompatButton
...

this worked for me