为了更好的学习和工作,动动小手收藏起来吧!
今天在小米系统中发现,在弹出更新的对话框中,点击了对话框的外面,对话框消失了。
很明显,这不是项目需要。
后查阅相关资料,通过设置setCancelable属性就行。
private void showDownloadDialog(){
AlertDialog.Builder builder = new Builder(mContext);
builder.setTitle("正在下载安装包,请稍候!");
final LayoutInflater inflater = LayoutInflater.from(mContext);
View v = inflater.inflate(R.layout.progress, null);
mProgress = (ProgressBar)v.findViewById(R.id.progress);
builder.setView(v);
builder.setNegativeButton("取消", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
interceptFlag = true;
}
});
downloadDialog = builder.create();
builder.setCancelable(false);
downloadDialog.setCanceledOnTouchOutside(false);
downloadDialog.show();
}
https://mp.weixin.qq.com/s/Q6b6sePMgJOpW2xDZob3Og