[android]代码库
1.按键添加一个onClick事件,执行dialog(View view)方法
public void clean(View view)
{
dialog();
}
//对话框
public void dialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(Data_Activity.this);
builder.setMessage("确认退出吗?");
builder.setTitle("提示");
builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Data_Activity.this.finish();
}
});
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}