使用单键的AlertDialog?

时间:2011-03-29 19:31:29

标签: android alertdialog

我真的想用单个按钮制作一个AlertDialog,有人可以指导我这个。谢谢!

3 个答案:

答案 0 :(得分:2)

答案 1 :(得分:2)

是的,你可以:

new AlertDialog.Builder(this)
.setIcon(R.drawable.icon)
.setTitle("Error")
.setMessage("Please fill out the entire form")
.setPositiveButton("Close", new DialogInterface.OnClickListener() {

    @Override
    public void onClick(DialogInterface dialog, int which) {

    }
})
.create()
.show()
;

答案 2 :(得分:0)

使用AlertDialog.Builder

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
    public onClick(DialogInterface dialog, int which) {
        // do something interesting.
    }
});
// other code to customize the dialog
Dialog d = builder.create();