Android 对话框上的自定义主题
我搜索了一个自定义对话框,发现添加主题是自定义Android 对话框上的自定义主题,android,eclipse,api,Android,Eclipse,Api,我搜索了一个自定义对话框,发现添加主题是自定义alertdialog的一种方法,每当我在我的alertdialog上添加android.R.style.theme\u Transparent\u NoTitleBar。我的程序在运行时强制关闭。我收到的调用需要API级别11(当前最小值为8):新的android.app.AlertDialog.Builder我需要安装API级别11吗 我的API是从8到19 这是我的密码: AlertDialog.Builder builder = new Al
alertdialog
的一种方法,每当我在我的alertdialog
上添加android.R.style.theme\u Transparent\u NoTitleBar
。我的程序在运行时强制关闭。我收到的调用需要API级别11(当前最小值为8):新的android.app.AlertDialog.Builder
我需要安装API级别11吗
我的API是从8到19
这是我的密码:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder = new AlertDialog.Builder(this, android.R.style.Animation_Dialog);
builder.setTitle("Exit");
builder.setMessage("Do you want to quit the game?");
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
finish();
}
});
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
}
我需要什么来使用这种不同的主题
请为我的问题道歉谢谢大家首先,为什么要创建两次对象:-
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder = new AlertDialog.Builder(this, android.R.style.Animation_Dialog);
接下来,您可能会在低于蜂巢(API 11)的设备上调试应用程序。但是AlertDialog.Builder(上下文,int主题)添加到API级别11中。因此,对于<11的版本,可以使用
Builder builder = new AlertDialog.Builder(new
ContextThemeWrapper(this,android.R.style.Theme_DeviceDefault_Light_Dialog));
你考虑过设置minSdkVersion14吗?您需要针对较低级别的api有什么原因吗?为了使我的程序与这些较低级别的api兼容?姜饼不再有很大的市场份额,尽管很明显,您是否决定target>=ICS取决于具体情况。同样值得注意的是,api 14已经(几乎)实现了3岁:先生@rahul我试过了,对话没有变化。怎么样?@user3691945你用你的风格替换了这个风格吗。你能给我看看密码吗