我在更改“警报对话框”的chexbox主题时遇到麻烦。我无法将所选复选框的颜色更改为我的AccentColor。
这是我的风格代码
<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:checkboxStyle">@style/CustomCheckBox</item>
</style>
<style name="CustomCheckBox" parent="android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/activated_checkbox</item>
</style>
Run Code Online (Sandbox Code Playgroud)
选择器:activated_checkbox
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- checked -->
<item android:state_checked="true" android:drawable="@color/AccentColor">
</item>
<item android:state_checked="false" android:drawable="@color/White">
</item>
</selector>
Run Code Online (Sandbox Code Playgroud)
和显示AlertDialog的方法。
private void showDialog() {
final CharSequence[] items = getResources().getStringArray(R.array.tipoDescargas);
final boolean[] states = {false, false, false};
AlertDialog.Builder builder = new AlertDialog.Builder(this,R.style.AlertDialogCustom);
builder.setTitle(getResources().getString(R.string.preguntaDescargas));
builder.setMultiChoiceItems(items, states, new DialogInterface.OnMultiChoiceClickListener() {
public void onClick(DialogInterface dialogInterface, int item, boolean state) {
}
});
builder.setPositiveButton("Descargar", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int …Run Code Online (Sandbox Code Playgroud)