Why is the Android Android Alert BLACK dialog box?

Can you help figure out why my BLACK alert dialog ?!

I recently changed the theme of my material design support application, but my alert dialog turned black!

Here is my code creation dialog:

AlertDialog.Builder alertDialog = new AlertDialog.Builder(TestActivity.this); alertDialog.setCancelable(true); alertDialog.setTitle("sample"); alertDialog.setItems(new String[] { "a", "b" }, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }); alertDialog.show(); 

and his style of my style and dialogue

 <style name="MaterialTheme" parent="Theme.AppCompat.NoActionBar"> <item name="android:alertDialogStyle">@style/AppDialog</item> <item name="android:alertDialogTheme">@style/AppDialog</item> <item name="android:textColor">@color/black</item> <item name="android:textColorPrimary">@color/black</item> <item name="android:dialogTheme">@style/AppDialog</item> <item name="colorPrimaryDark">@color/myPrimaryDarkColor</item> <item name="android:textColorHint">@color/gray_1</item> <item name="colorAccent">@color/myAccentColor</item> <item name="drawerArrowStyle">@style/DrawerArrowStyle</item> <item name="android:windowBackground">@color/black</item> </style> <style name="AppDialog" parent="Theme.AppCompat.Light.Dialog.Alert"> <item name="colorAccent">#FFC107</item> <item name="android:textColorPrimary">#FFFFFF</item> <item name="android:background">#4CAF50</item> </style> 
+6
source share
3 answers

You do not specify a theme for AlertDialog, to use a theme, change the code to:

 ContextThemeWrapper ctw = new ContextThemeWrapper(TestActivity.this, R.style.AppDialog); AlertDialog.Builder alertDialog = new AlertDialog.Builder(ctw); 
+4
source

you should use a light theme with your alertdialog constructor like THEME_HOLO_LIGHT.

 AlertDialog.Builder alertDialog = new AlertDialog.Builder(this,AlertDialog.THEME_HOLO_LIGHT); 
+3
source

see excluded arrays, maybe you can solve your problem with this approach.

How to change the background of Android alert dialogs?

+1
source

All Articles