2011-03-29 106 views
1

我真的想用單個按鈕製作AlertDialog,有人可以用這個指導我。謝謝!AlertDialog單按鈕?

+3

任何線索?語言,平臺,網絡/桌面 – 2011-03-29 19:38:19

+0

我想在android – 2011-03-29 19:39:09

+0

中創建一個Alert Dialog您正在使用哪種語言和/或平臺? 'AlertDialog'可能來自Android,那是你在做什麼? – jmccarthy 2011-03-29 19:40:03

回答

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