Can you help my figure out why is my alert dialog BLACK?!
Recently i changed my app theme to support material design, but my alert dialog got black!
Here is my create dialog Code:
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 its my main style and dialog style
<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>
AlertDialog is a lightweight version of a Dialog. This is supposed to deal with INFORMATIVE matters only, That's the reason why complex interactions with the user are limited. Dialog on the other hand is able to do even more complex things .
Android AlertDialog can be used to display the dialog message with OK and Cancel buttons. It can be used to interrupt and ask the user about his/her choice to continue or discontinue. Android AlertDialog is composed of three regions: title, content area and action buttons.
You don't set theme for AlertDialog, for using theme, change code to:
ContextThemeWrapper ctw = new ContextThemeWrapper(TestActivity.this, R.style.AppDialog);
AlertDialog.Builder alertDialog = new AlertDialog.Builder(ctw);
you must use a light theme with your alertdialog builder such as the THEME_HOLO_LIGHT.
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this,AlertDialog.THEME_HOLO_LIGHT);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With