0

After I have put in AndroidManifest.xml:

<application
    android:allowBackup="true"
    android:icon="@drawable/icon"
    android:label="@string/app_name"
    android:theme="@style/myTheme" >

and in styles.xml:

<style name="myTheme" parent="android:Theme">
<item name="android:background">@color/BG</item>
<item name="android:windowNoTitle">true</item>
</style>

The background color of every dialog alert became the color BG, how can I put the default background without removing that?

DialogInterface.OnClickListener dialogClickListener=new DialogInterface.OnClickListener()
        {
            @Override
            public void onClick(DialogInterface dialog, int which)
            {
                switch(which)
                {
                    case DialogInterface.BUTTON_POSITIVE:
                        //Some code
                    break;

                    case DialogInterface.BUTTON_NEGATIVE:
                    //Some code
                    break;
                }
            }
        };

        AlertDialog.Builder builder=new AlertDialog.Builder(this);
        builder.setMessage("Are you sure? (Reset)").setPositiveButton("Yes", dialogClickListener).setNegativeButton("No", dialogClickListener).show();
Mageek
  • 3,758
  • 5
  • 36
  • 56
  • Could you just use a different style for the view? See http://stackoverflow.com/a/5134920/724068 – Nick Caballero Oct 19 '13 at 15:50
  • @NickCaballero how can I do that with the dialogbuilder? – Mageek Oct 19 '13 at 15:56
  • Ah I missed that part. Take a look at this question :http://stackoverflow.com/questions/2422562/how-to-change-theme-for-alertdialog – Nick Caballero Oct 19 '13 at 15:59
  • @NickCaballero Thanks, it's almost that, but now what is the style for the default DialogAlert? – Mageek Oct 19 '13 at 16:05
  • @NickCaballero Doing `AlertDialog.Builder builder=new AlertDialog.Builder(new ContextThemeWrapper(this, android.R.style.Theme_Dialog));` didn't work – Mageek Oct 19 '13 at 16:10

1 Answers1

0

Try this if you have a custom layout for AlertDialog:

View dialogView = View.inflate(new ContextThemeWrapper(this, android.R.style.Theme_Dialog),R.layout.dialogLayout, null);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(dialogView);
ramaral
  • 6,079
  • 4
  • 32
  • 55