当前位置:网站首页>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 需要做空判断.
边栏推荐
- ARM Mailbox
- Understand the recommendation system in one article: Recall 06: Two-tower model - model structure, training method, the recall model is a late fusion feature, and the sorting model is an early fusion
- Unleashing the engine of technological innovation, Intel joins hands with ecological partners to promote the vigorous development of smart retail
- Programmer's list of sheep counting when insomnia | Daily anecdote
- 学习笔记-----左偏树
- Flink 1.15.1 集群搭建(StandaloneSession)
- Opening - Open a new .NET modern application development experience
- [ROS](10)ROS通信 —— 服务(Service)通信
- 没有对象的程序员如何过七夕
- “嘀哩哩,等灯等灯”,工厂安全生产的提示音
猜你喜欢

如何逐步执行数据风险评估

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

Jincang database KingbaseES V8 GIS data migration solution (3. Data migration based on ArcGIS platform to KES)

Apache DolphinScheduler新一代分布式工作流任务调度平台实战-中

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

iNFTnews | What can NFTs bring to the sports industry and fans?

树表的查找

【LeetCode刷题】-数之和专题(待补充更多题目)

释放技术创新引擎,英特尔携手生态合作伙伴推动智慧零售蓬勃发展

.Net C# Console Create a window using Win32 API
随机推荐
SDC简介
leetcode 15
Dotnet 6 Why does the network request not follow the change of the system network proxy and dynamically switch the proxy?
[Decryption] Can the NFTs created by OpenSea for free appear in my wallet without being chained?
Domain Driven Design - MDD
Common hardware delays
Access Characteristics of Constructor under Inheritance Relationship
select tag custom style
select 标签自定义样式
[Unity Entry Plan] Handling of Occlusion Problems in 2D Games & Pseudo Perspective
[LeetCode Brush Questions] - Sum of Numbers topic (more topics to be added)
01 【前言 基础使用 核心概念】
转:查尔斯·汉迪:你是谁,比你做什么更重要
使用OpenVINO实现飞桨版PGNet推理程序
海量服务实例动态化管理
nodeJs--encapsulate routing
如何逐步执行数据风险评估
程序员失眠时的数羊列表 | 每日趣闻
蚁剑高级模块开发
"Dilili, wait for the lights, wait for the lights", the prompt sound for safe production in the factory