[android]代码库
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setIcon(R.drawable.ic_launcher);
builder.setTitle("你确定要离开吗?");
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// 这里添加点击确定后的逻辑
new AlertDialog.Builder(MainActivity.this).setMessage("你选择了确定")
.show();
}
});
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// 这里添加点击确定后的逻辑
new AlertDialog.Builder(MainActivity.this).setMessage("你选择了取消")
.show();
}
});
builder.create().show();
[代码运行效果截图]