简体   繁体   中英

Android Alert Dialog text color

In my application I am trying to switch the themes between light and dark. But the Alert Dialog text color is not changed with the theme. I have created a theme for the Alert Dialog but does not seem to be working. Here is my code :

    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();

my styles.xml

   <style name="DialogWhite" parent="@android:style/Theme.Dialog">
    <item name="android:textColor">?android:attr/textColorPrimaryInverseDisableOnly</item>
    </style>

Can anyone help me with this?

Making custom dialog is much simpler to produce most fit UIs in this case. Since only limited themes are provided in AlertDialog

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM