Skip to content

Instantly share code, notes, and snippets.

@aztack
Created January 22, 2012 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aztack/1655842 to your computer and use it in GitHub Desktop.
Save aztack/1655842 to your computer and use it in GitHub Desktop.
alert dialog with 2 buttons android
protected void AlertDialog() {
AlertDialog.Builder builder = new Builder(Main.this);
builder.setMessage("确认退出吗?");
builder.setTitle("提示");
builder.setPositiveButton("确认", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Main.this.finish();
}
});
builder.setNegativeButton("取消", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment