为了更好的学习和工作,动动小手收藏起来吧!
今天在小米系统中发现,在弹出更新的对话框中,点击了对话框的外面,对话框消失了。
后查阅相关资料,通过设置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();
}
爱开发
微信号:aikaifa
联系客服