只需在dialog的show方法前调用 setCanceledOnTouchOutside setCancelable 这两个方法即可 并设置参数为false 代码如下:
代码语言:javascript复制Builder builder = new Builder(mContext);
builder.setTitle("软件版本更新");
builder.setMessage(updateMsg);
builder.setNegativeButton("下载", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int arg1) {
// TODO Auto-generated method stub
dialog.dismiss();
}
});
noticeDialog = builder.create();
//设置点击屏幕不消失
noticeDialog.setCanceledOnTouchOutside(false);
//设置点击返回键不消失
noticeDialog.setCancelable(false);
noticeDialog.show();