0
我一直试图通过使其链接到xml文件来将此alertDialog设置为线性视图。但它不工作。任何帮助,将不胜感激,感谢名单将AlertDialog设置为线性视图
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure you want to exit?")
.setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MyActivity.this.finish();
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
我将如何引用xml中的按钮名称它不像只是设置一个名为button = yes的变量;你有任何想法,不管thanx – Hashey100 2012-03-06 14:53:27
在XML中说''并且在你的代码中你说'Button mButton =(Button)myLayout.findViewByID .id.button1));'但是你也可以像上面的代码一样使用Positive和Negative Button。它们将被自动放置在LinearLayout之下。 – Thommy 2012-03-06 14:59:06
Ty老兄我会去工作 – Hashey100 2012-03-06 15:03:49