new AlertDialog.Builder(activity)
.setMessage(R.string.title_cancel_alertdialog)
.setPositiveButton(“確認”, new DialogInterface.OnClickListener() {//確認按鈕
public void onClick(DialogInterface arg0, int arg1) {
//按鈕點擊後觸發的動作,點擊後對話框是自動消失的
}
})
.setNegativeButton("取消", new DialogInterface.OnClickListener() {//取消按鈕
public void onClick(DialogInterface arg0, int arg1) {
//按鈕點擊後觸發的動作,點擊後對話框是自動消失的
}
}).show();