不知道什麼原因,Android-Alert Dialog 不能顯示在屏幕上。當按下一個按鈕時,觸發這個事件,但是對話框還是不顯示。如何改進?
AlertDialog.Builder builder = new AlertDialog.Builder(SummaryActivity.this);
builder.setTitle(R.string.please_confirm)
.setMessage(R.string.terms_details)
.setCancelable(false)
.setPositiveButton(R.string.sign_to_agree, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent DrawIntent = new Intent(getApplicationContext(), DrawingActivity.class);
startActivity(DrawIntent);
}
})
.setNegativeButton(R.string.cancel_button_label, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
最後加一句
alert.show();
既可