I am using a style to well, style my Alert Dialog, most of it is styled as you can see below but the multichoice items are not getting the color change. I would also like to have the checkboxes in white but am not sure how to do that.
Alert Dialog:
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(this, R.style.AlertDialogDarkBlue);
builder.setTitle("Faulty Part");
final ArrayList<Integer> selectedFaults = new ArrayList<>();
builder.setMultiChoiceItems(faultsList, null, new DialogInterface.OnMultiChoiceClickListener(){
@Override
public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked) {
if (isChecked) {
// If the user checked the item, add it to the selected items
selectedFaults.add(indexSelected);
} else if (selectedFaults.contains(indexSelected)) {
// Else, if the item is already in the array, remove it
selectedFaults.remove(Integer.valueOf(indexSelected));
}
}
});
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
onResume();
}
});
android.app.AlertDialog alert = builder.create();
alert.show();
AlertDialogBlue style:
<style name="AlertDialogDarkBlue" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:textColor">@color/colorWhite</item>
<item name="textColorAlertDialogListItem">@color/colorWhite</item>
<item name="android:background">@color/colorDarkBlue</item>
</style>
How it currently looks:
To fix the text color to white, just extend in your custom Style the AppCompat.Dark
instead of the AppCompat.Light
.
To edit the CheckBoxes
selected color, you can override the colorAccent
in your custom style and it will be applyied only to the element using that style.
This is an example:
<style name="AlertDialogDarkBlue" parent="Theme.AppCompat.Dark.Dialog.Alert">
<item name="android:textColor">@color/colorWhite</item>
<item name="textColorAlertDialogListItem">@color/colorWhite</item>
<item name="android:background">@color/colorDarkBlue</item>
<!-- those to edit the color of checkboxes (I don't remember if both are needed or just one) -->
<item name="android:colorAccent">@color/dialogCheckboxesColor</item>
<item name="colorAccent">@color/dialogCheckboxesColor</item>
</style>
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With