2012-08-27 23 views

回答

3

它只是一個助手類,它允許您調用鏈中的方法並輕鬆設置正/負按鈕。例如:

AlertDialog.Builder

AlertDialog.Builder alert = new AlertDialog.Builder(this) 
    .setTitle("this is title") 
    .setMessage("this is message") 
    .setCancelable(false) 
    .setPositiveButton("OK", null); 
    alert.show(); 

AlertDialog

AlertDialog alert2 = new AlertDialog.Builder(this).create(); 
alert2.setTitle("this is title"); 
alert2.setMessage(""); 
alert2.setCancelable(false); 
alert2.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() { 
    @Override 
    public void onClick(DialogInterface dialog, int which) { 
     // null 
    } 
}); 
alert2.show(); 

所以,現在你可以看到難易程度兩種不同的方式創造同樣的事情的差異。