当前位置:网站首页>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 需要做空判断.
边栏推荐
- DAY23: Command Execution & Code Execution Vulnerability
- [LeetCode Brush Questions] - Sum of Numbers topic (more topics to be added)
- C学生管理系统 头添加学生节点
- 关于#sql shell#的问题,如何解决?
- 释放技术创新引擎,英特尔携手生态合作伙伴推动智慧零售蓬勃发展
- 亚马逊云科技 + 英特尔 + 中科创达为行业客户构建 AIoT 平台
- Transfer Learning - Joint Geometrical and Statistical Alignment for Visual Domain Adaptation
- C student management system head to add a student node
- dotnet 6 为什么网络请求不跟随系统网络代理变化而动态切换代理
- Greenplum Database Fault Analysis - Why Does gpstart -a Return Failure After Version Upgrade?
猜你喜欢
随机推荐
Simple implementation of YOLOv7 pre-training model deployment based on OpenVINO toolkit
HOG特征学习笔记
[ROS](10)ROS通信 —— 服务(Service)通信
重新审视分布式系统:永远不会有完美的一致性方案……
C language basics -- pointers
Opening - Open a new .NET modern application development experience
树形查找(二叉查找树)
[ROS] (10) ROS Communication - Service Communication
Live preview | 30 minutes started quickly!Look at credible distributed AI chain oar architectural design
编译预处理等细节
英特尔 XDC 2022 精彩回顾:共建开放生态,释放“基建”潜能
02 [Development Server Resource Module]
How to create an rpm package
Greenplum Database Fault Analysis - Can a Soft Connection Be Made to the Database Base Folder?
如何逐步执行数据风险评估
转:查尔斯·汉迪:你是谁,比你做什么更重要
Quickly learn chess from zero to one
领域驱动设计——MDD
PHP技能评测
DAY23:命令执行&代码执行漏洞





![01 [Foreword Basic Use Core Concepts]](/img/90/67537d5fad28d68766ca85b887839e.png)


![[ROS] (10) ROS Communication - Service Communication](/img/4d/4657f24bd7809abb4bdc4b418076f7.png)
