I'm constructing a dialog with multi-choice items (checkboxes):
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMultiChoiceItems(arrayResource, selectedItems, new DialogInterface.OnMultiChoiceClickListener() {
// ...
});
AlertDialog dialog = builder.create();
dialog.show();
And I have a custom style for checkboxes:
<style name="CustomCheckBox" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/btn_check</item>
<item name="android:textColor">@android:color/holo_purple</item>
</style>
It works perfectly when applied to individual checkboxes in the layout, by setting style="@style/CustomCheckBox"
.
But how can I apply this style to the created dialog? Or alternatively for the entire theme...
If it's somehow relevant - I'm using minSdkVersion=14
and targetSdkVersion=19
.
Update:
Now according to MattMatt's answer, I'm applying a custom checkbox style to the entire theme, and also settings a custom style for dialogs:
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:checkboxStyle">@style/CustomCheckBox</item>
<item name="android:dialogTheme">@style/CustomDialog</item>
<item name="android:alertDialogTheme">@style/CustomDialog</item>
</style>
<style name="CustomCheckBox" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/btn_check</item>
<item name="android:checkMark">@drawable/btn_check</item>
</style>
<style name="CustomDialog" parent="@android:style/Theme.Holo.Light.Dialog">
<item name="android:checkboxStyle">@style/CustomCheckBox</item>
<item name="android:background">#aaf</item>
</style>
Now any checkbox added to the layout gets the custom style, and I'm able to change the dialog's background, but the checkboxes in the dialog aren't affected in any way...