在我的应用程序中,我试图在明暗之间切换主题。但是警报对话框文本颜色不会随主题而改变。我为警报对话框创建了一个主题,但似乎不起作用。这是我的代码:
final AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(mContext, R.style.DialogWhite));
builder.setAdapter(adapter, new OnClickListener() {
@Override
public void onClick(final DialogInterface dialog, final int which) {
final ActionBarItemResource eab = aList.get(which);
eab.getAction().run();
}
});
// builder.setTitle(tEntityNew.getName());
final AlertDialog alert = builder.create();
alert.show();
我的样式.xml
<style name="DialogWhite" parent="@android:style/Theme.Dialog">
<item name="android:textColor">?android:attr/textColorPrimaryInverseDisableOnly</item>
</style>
谁能帮我这个?