Change the background color of a pop-up dialog

android, android-alertdialog, background-color

Solution

If you just want a light theme and aren't particular about the specific color, then you can pass a theme id to the AlertDialog.Builder constructor.

AlertDialog.Builder(this, AlertDialog.THEME_HOLO_LIGHT)...

or

AlertDialog.Builder(this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT)...

Problem

I wrote android code that shows a pop-up dialog but I want to change the background color from black to white , and then the color of the writing. This is the dialog's code: ``` mPrefs = PreferenceManager.getDefaultSharedPreferences(this); Boolean welcomeScreenShown = mPrefs.getBoolean(welcomeScreenShownPref, false); if (!welcomeScreenShown) { String whatsNewText = getResources().getString(R.string.Text); new AlertDialog.Builder(this).setMessage(whatsNewText).setPositiveButton( R.string.ok, new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).show(); SharedPreferences.Editor editor = mPrefs.edit(); editor.putBoolean(welcomeScreenShownPref, true); editor.commit(); // Very important to save the preference } ```

Original source