当前位置:网站首页>RecyclerView设置缓存大小
RecyclerView设置缓存大小
2022-08-10 22:16:00 【今人不见古时月,今月曾经照古人】
前两天遇到问题,RecyclerView使用GridView布局,滑出界面两行再划回来,只有第一行只有前两个grid位置的控件还保留原来功能,后面的都失活了,觉得是控件的问题,然后最终解决,以下是帮助了我的文章,收藏!有时间详细学习!
段落1
熟悉RecyclerView 缓存的同学应该知道(后面在也会介绍RecyclerView缓存机制),当RecyclerView中的itemView 滑出屏幕后会缓存在mCacheView 中(默认缓存最大数是2),因此当滑出屏幕超过2后,再滑回来,原来的位置信息都会被重置。
段落2
滑动场景中的复用会用到这里的机制。mCachedViews 的大小默认为2。遍历 mCachedViews,找到 position 一致的 ViewHolder,之前说过,mCachedViews 里存放的 ViewHolder 的数据信息都保存着,所以 mCachedViews 可以理解成,只有原来的卡位可以重新复用这个 ViewHolder,新位置的卡位无法从 mCachedViews 里拿 ViewHolder出来用。
RecyclerView回收和复用机制分析(这篇讲的非常好,完美的解决了我的困惑)
段落3
你可以调用
recyclerView.setItemViewCacheSize(int);
这个 api,去调整 RecyclerView 的复用逻辑和方式来解决 onBindViewHolder 没有调用的这个问题。
其他:
边栏推荐
- August 10, 2022: Building Web Applications for Beginners with ASP.NET Core -- Creating Web UIs with ASP.NET Core
- What are the concepts, purposes, processes, and testing methods of interface testing?
- 爬虫request.get()出现错误
- Introduction to the use of counter instructions in Rockwell AB PLC RSLogix5000
- 带着昇腾去旅行:一日看尽金陵城里的AI胜景
- Common interview questions for APP UI automation testing, maybe useful~
- DC-7靶场下载及渗透实战详细过程(DC靶场系列)
- Pro-test is effective | A method to deal with missing features of risk control data
- 金山云CEO王育林离职:正值冲刺港股之际 雷军曾送金砖
- “数据引擎”开启前装规模量产新赛道,「智协慧同」崭露头角
猜你喜欢

使用 Cloudreve 搭建私有云盘

geemap的详细安装步骤及环境配置

解码2022中国网安强星丨正向建、反向查,华为构建数字化时代的网络安全防线

《DevOps围炉夜话》- Pilot - CNCF开源DevOps项目DevStream简介 - feat. PMC成员胡涛

Shell programming specification and variables

shell(文本打印工具awk)

【640. Solving Equations】

Why general company will say "go back messages such as" after the end of the interview, rather than just tell the interviewer the result?

“数据引擎”开启前装规模量产新赛道,「智协慧同」崭露头角

交换机和生成树知识点
随机推荐
企业云存储日常运行维护实践经验分享
JS use regular expressions in g model and non g difference
FPGA - Memory Resources of 7 Series FPGA Internal Structure -03- Built-in Error Correction Function
3598. Binary tree traversal (Huazhong University of Science and Technology exam questions)
Research on multi-element N-k fault model of power system based on AC power flow (implemented by Matlab code) [Power System Fault]
链表中的节点每k个一组翻转
罗克韦尔AB PLC RSLogix5000中计数器指令使用方法介绍
德科立科创板上市:年营收7.3亿 市值59亿
CIKM2022 | 基于双向Transformers对比学习的序列推荐
What would happen if disconnecting during the process of TCP connection?
RK3399 platform development series explanation (kernel-driven peripherals) 6.35, IAM20680 gyroscope introduction
Shell编程规范与变量
STL-stack
shell(文本打印工具awk)
解码2022中国网安强星丨正向建、反向查,华为构建数字化时代的网络安全防线
How to be a Righteous Hacker?What should you study?
CIKM2022 | Sequence Recommendation Based on Bidirectional Transformers Contrastive Learning
shell programming without interaction
The Thread State,
C # Hex file transfer skills necessary article 】 【 bin file code implementation