Issue
I am using a library to show some nice dialogs. I now came to the point where I am getting crashes. If I pass a resource (Eg. R.color.thatRedColor), the dialog will have a red background color. When I am passing an Integer (as it should be used), the app just crashes.. Is there any way that I can pass a valid value using an Integer?
The used line in my colors.xml
<color name="indigo">#3f51b5</color>
My code
int primaryColor = 11243910;
new MaterialStyledDialog(context)
.setHeaderColor() //If I pass R.color.indigo, it works. If I pass primaryColor, it crashes..
.setDescription("Hello")
.setPositive("Ok", new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
//Do something
}
})
.setNegative("No", new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
//Don't do anything
}
})
.withDivider(false)
.show();
Solution
Based on the source code, use setHeaderColorInt()
, not setHeaderColor()
, to pass an actual color value instead of a color resource ID.
In case you get a package clash, add the following:
compile ('com.github.javiersantos:MaterialStyledDialogs:1.5.5') {
exclude group: 'com.afollestad.material-dialogs';
}
Answered By - CommonsWare
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.