当前位置:网站首页>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 没有调用的这个问题。
其他:
边栏推荐
- Conditional Statements of Shell Programming (2)
- camera preview process --- from HAL to OEM
- Extended Chinese Remainder Theorem
- 高数_复习_第5章:多元函数微分学
- RK3399 platform development series explanation (kernel-driven peripherals) 6.35, IAM20680 gyroscope introduction
- Detailed installation steps and environment configuration of geemap
- 68:第六章:开发文章服务:1:内容梳理;article表介绍;创建【article】文章服务;
- DC-8靶场下载及渗透实战详细过程(DC靶场系列)
- MySQL Advanced Commands
- MySQL: MySQL Cluster - Principle and Configuration of Master-Slave Replication
猜你喜欢
随机推荐
C # Hex file transfer skills necessary article 】 【 bin file code implementation
file IO-buffer
《DevOps围炉夜话》- Pilot - CNCF开源DevOps项目DevStream简介 - feat. PMC成员胡涛
12 Recurrent Neural Network RNN2 of Deep Learning
gcc492 compile `.rodata‘ can not be used when making a PIE object; recompile with -fPIE
OneNote tutorial, how to organize notebooks in OneNote?
win系统下pytorch深度学习环境安装
2021IDEA创建web工程
CIKM2022 | Sequence Recommendation Based on Bidirectional Transformers Contrastive Learning
JS use regular expressions in g model and non g difference
阿里云新增三大高性能计算解决方案,助力生命科学行业快速发展
How to be a Righteous Hacker?What should you study?
LeetCode每日两题01:反转字符串 (均1200道)方法:双指针
DC-8靶场下载及渗透实战详细过程(DC靶场系列)
Shell编程之条件语句(二)
LeetCode Daily 2 Questions 02: Reverse the words in a string (1200 each)
CFdiv2-Beautiful Mirrors-(期望)
边缘与云计算:哪种解决方案更适合您的连接设备?
STL-deque
华为HCIE云计算之Fusion Access桌面云







