How do you get the black themed Dialog in android like shown on the android guide http://developer.android.com/guide/topics/ui/dialogs.html
I took a screen shot. Whenever I use Alert Dialog, I get the dialog on the left, I want the one on the right.
Add custom_layout. xml in that activity in which you want to show custom alert dialog here it is added in MainActivity. java.
res/values/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="default_activity_theme" parent="@android:style/Theme.Holo"/>
</resources>
AndroidManifest.xml
<activity android:name=".ActivityMain"
android:theme="@style/default_activity_theme"/>
It's simple for API 11 onwards:
AlertDialog.Builder alert = new AlertDialog.Builder(context, AlertDialog.THEME_DEVICE_DEFAULT_DARK);
The field THEME_DEVICE_DEFAULT_DARK
was added in API 14 so if you are targeting before then, just use the numeric value, thus:
AlertDialog.Builder alert = new AlertDialog.Builder(context, 4);
The different constants you can use, and their values are shown here. On pre API 14 you will still get the white alert though.
----------------------------------------------------------------UPDATE--------------------------------------------------------
AlertDialog.THEME_DEVICE_DEFAULT_DARK
is depreciated,
Below is the updated code:
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this, android.R.style.Theme_DeviceDefault_Light_Dialog_Alert);
You can choose different themes instead of this android.R.style.Theme_DeviceDefault_Light_Dialog_Alert
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