Change text color of alert dialog

Solution 1:

You have to provide a custom style id in the AlertDialog constructor:

AlertDialog.Builder(Context context, int themeResId)

and the style file should be something like:

<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="android:colorAccent">#0000FF</item>
</style>

Solution 2:

Change your method to

private void showDownloadPgmPopup() {

    android.app.AlertDialog.Builder builder = new android.app
               .AlertDialog.Builder(getActivity(),R.style.AlertDialog);
...
..
.   
}

And under res/values/styles.xml add a new AlertDialog style

<style name="AlertDialog" parent="Base.Theme.AppCompat.Light.Dialog">
        <item name="android:textColor">#000000</item>
        <item name="android:textColorPrimary">#595959</item>
        <item name="android:colorAccent">#1b5e20</item>
    </style>

Below is the screen shot of these changes

See dialog box color changes