当我试图将一个标准主题应用到AlertDialog
AlertDialog主题:如何更改项目文本颜色?
AlertDialog.Builder builder = new AlertDialog.Builder(MyClass.this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
builder.setTitle("Change");
String[] info= this.getResources().getStringArray(R.array.info);
ArrayAdapter arrayAdapter = new ArrayAdapter(this, android.R.layout.select_dialog_singlechoice);
arrayAdapter.addAll(info);
builder.setSingleChoiceItems(arrayAdapter, ....
结果:
的注意的是,我有没有问题builder.setItems(...)
因为它的文本颜色为Black
,而应用的主题与builder.setSingleChoiceItems(...)
有一个白色的文字颜色。
任何快速修复?或者以任何方式创建基于AlertDialog.THEME_DEVICE_DEFAULT_LIGHT
的自定义主题?
预期我的个性风格不起作用:
<style name="AlertDialogCustomTheme" android:parent="android:Theme.Dialog">
<item name="android:textColor">#7ABDFF</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<!--THE FOLLOWING ITEMS HAVE NOT EFFECT ... !! -->
<item name="android:layout_centerHorizontal">true</item>
<item name="android:layout_centerVertical">true</item>
<item name="android:textColorAlertDialogListItem">#A844BD</item>
<item name="android:itemBackground">#7ABDFF</item>
</style>
更新
@lopez答案是一个完整的解决方案,但我发现一个单行修复我的问题,自定义主题适用于清单中的活动:
<style name="MyTheme">
<item name="android:textColorAlertDialogListItem">@android:color/black</item>
</style>
不幸的属性仅适用于API 11及更高版本 – jiduvah