打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Android中Alertdialog对话框点击屏幕外部消失问题
userphoto

2022.08.02 广东

关注


为了更好的学习和工作,动动小手收藏起来吧!

今天在小米系统中发现,在弹出更新的对话框中,点击了对话框的外面,对话框消失了。


很明显,这不是项目需要。

后查阅相关资料,通过设置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

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
AlertDialog弹出自定义对话框
Android setContentView 实现同一个activity下不同view的切换
按照预期初始化布局--layout inflation as intended
LayoutInflater作用及使用
Layout Inflation as Intended
AlertDialog和AlertDialog.Builder?两者区别
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服