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();
4

1 回答 1

0

如果您有 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);
于 2013-10-19T16:30:02.953 回答