自定义Dialog dismiss时 View not attached to window manager
来源:互联网 发布:网络婚姻游戏 编辑:程序博客网 时间:2024/05/16 05:14
自定义Dialog 用来显示加载动画,自定义dialog有个定时器,当超过一定时间的时候,会自动dismiss掉dialog,但是当页面已经关闭的时候,这两个dismiss操作会重复,所以dismiss dialog会crash报错。
View not attached to window manager
解决方法,可以设置dialog的setOwnerActivity为当前页面,在dismiss时候判断Activity是否已经关闭,
如下:
1、添加设置dialog的setOwnerActivity
context为创建dialog对象,传递进去当前页面,
dialog.setOwnerActivity((Activity) context);
2、dialogdismiss判断
//得到dialog的OwnerActivityActivity activity = dialog.getOwnerActivity();//判断页面是否关闭if ( activity != null && !activity.isFinishing()) dialog.dismiss();
阅读全文
0 0
- 自定义Dialog dismiss时 View not attached to window manager
- ProgressDialog dismiss not attached to window manager
- dialog , not attached to window manager
- view not attached to window manager
- View not attached to window manager
- illegalargumentexception: view not attached to window manager
- View not attached to window manager
- View not attached to window manager解决方案
- View not attached to window manager
- View not attached to window manager解决方案
- View not attached to window manager解决方案
- View not attached to window manager解决方案
- View not attached to window manager解决方案
- View not attached to window manager解决方案
- View not attached to window manager解决方案
- View not attached to window manager
- android View not attached to window manager
- View not attached to window manager
- 关于托管磁盘的复制
- QT线程出现错误Cannot create children for a parent that is in a different thread
- Maven第四篇【私有仓库、上传jar包、引用私服jar包、上传本地项目到私服】
- 几种弹框的方式
- java 带根号的开平方
- 自定义Dialog dismiss时 View not attached to window manager
- 借助jd-gui工具查看jar源码
- python中的eval函数
- 物料主数据增强
- 一个比较有意思的评论留言
- DockerCon2017 Euro D1:宣布同时支持Swarm和Kubernetes
- JSP页面获取当前日期
- HDU-1005 Number Sequence
- 选择云会计软件时需要考虑的3点行业趋势