我放入AndroidManifest.xml后:
<application
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/myTheme" >
并在styles.xml中:
<style name="myTheme" parent="android:Theme">
<item name="android:background">@color/BG</item>
<item name="android:windowNoTitle">true</item>
</style>
每个对话框警报的背景颜色变成了颜色BG,如何在不删除背景的情况下放置默认背景?
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();
答案 0 :(得分: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);