F0RIS / sweet-alert-dialog

SweetAlert for Android, a beautiful and clever alert dialog
http://www.pedant.cn
287 stars 82 forks source link

setCancelButtonBackgroundColor not working #45

Open mbohnearschi opened 4 years ago

mbohnearschi commented 4 years ago
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)
Mr-ARBN commented 4 years ago

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

mofei666 commented 4 years ago

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

hamaz562006 commented 4 years ago

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

hammadexp commented 4 years ago

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?

mortezarakhtiani commented 4 years ago

// alert_dialog

<Button ....

to

<androidx.appcompat.widget.AppCompatButton ...

this worked for me