android弹出对话框中带有确定和取消对话框带事件的应用

来源:互联网 发布:北京seo服务 编辑:程序博客网 时间:2024/05/21 09:08

上次看了一个关于android中对话框的使用,其中对带确定和取消的对话框讲的并不详细,自己补全了一下,当确定和取消按钮中有事件时的情况,没事件时用null就行了

new AlertDialog.Builder(this).setTitle("标题").setMessage("提示的信息")

.setPositiveButton("确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which){
dialog.dismiss();
// SysPassDao pass = new SysPassDao(MainActivity.this);这里是自己写的方法,其他的是都需要的
// pass.roleAll();
MainActivity.this.finish();
}
})
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).show();
0 0
原创粉丝点击