当前位置:网站首页>View handler 踩坑记录
View handler 踩坑记录
2022-08-05 02:24:00 【吃饱很舒服】
问题
view 执行 onDetachedFromWindow 后, view 实例还会存在, 但 view 中的 handler 会被置空, 当使用到 view 中的 handler 时, 需要做出空判断
原理
view 的 handler 通过 view.getHandler() 获取, 下图可见, handler 从 mAttachInfo 中获取, mAttachInfo 在 dispatchAttachedToWindow 中赋值, 在 dispatchDetachedFromWindow 中置空, 其中 dispatchAttachedToWindow 会调用 view 的 onAttachedToWindow, dispatchDetachedFromWindow 中会调用 view 的 onDetachedFromWindow.



结论
所以首先我们要在 view 的 onDetachedFromWindow 中 移除 handler 的 runnable 或 callback, 在其他使用 handler 的时机, handler 需要做空判断.
边栏推荐
- Xunrui cms website cannot be displayed normally after relocation and server change
- SuperMap iDesktop.Net之布尔运算求交——修复含拓扑错误复杂模型
- EBS uses virtual columns and hint hints to optimize sql case
- 网络安全与元宇宙:找出薄弱环节
- 【OpenCV 图像处理2】:OpenCV 基础知识
- Live preview | 30 minutes started quickly!Look at credible distributed AI chain oar architectural design
- 在这个超连接的世界里,你的数据安全吗
- 【MySQL series】- Does LIKE query start with % will make the index invalid?
- 如何看待自己的羞愧感
- Advanced Numbers_Review_Chapter 1: Functions, Limits, Continuity
猜你喜欢

Matlab map with color representation module value size arrow

使用SuperMap iDesktopX数据迁移工具迁移地图文档和符号

J9数字货币论:web3的创作者经济是什么?

直播预告|30分钟快速入门!来看可信分布式AI链桨的架构设计

CPDA|运营人如何从负基础学会数据分析(SQL)
![[LeetCode Brush Questions] - Sum of Numbers topic (more topics to be added)](/img/ee/6b52072c841af99488dc0c1141c74c.png)
[LeetCode Brush Questions] - Sum of Numbers topic (more topics to be added)

Pisanix v0.2.0 发布|新增动态读写分离支持

leetcode 15

【MySQL系列】- LIKE查询 以%开头一定会让索引失效吗

sql语句多字段多个值如何进行排序
随机推荐
优化Feed流遭遇拦路虎,是谁帮百度打破了“内存墙”?
协作D2D局部模型聚合的半分散联合学习
编译预处理等细节
C语言日记 9 if的3种语句
.Net C# Console Create a window using Win32 API
亚马逊云科技 + 英特尔 + 中科创达为行业客户构建 AIoT 平台
01 [Foreword Basic Use Core Concepts]
Apache DolphinScheduler新一代分布式工作流任务调度平台实战-中
如何基于OpenVINO POT工具简单实现对模型的量化压缩
亚马逊云科技携手中科创达为行业客户构建AIoT平台
ExcelPatternTool: Excel table-database mutual import tool
Leetcode brushing questions - 22. Bracket generation
LeetCode使用最小花费爬楼梯----dp问题
基于OpenVINO工具套件简单实现YOLOv7预训练模型的部署
特殊矩阵的压缩存储
[Word] #() error occurs after Word formula is exported to PDF
力扣-二叉树的最大的深度
".NET IoT from scratch" series
Simple implementation of YOLOv7 pre-training model deployment based on OpenVINO toolkit
后期学习计划