当前位置:网站首页>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 没有调用的这个问题。
其他:
边栏推荐
- C # Hex file transfer skills necessary article 】 【 bin file code implementation
- HighTec shortcut keys (Keys) setting location
- xshell (sed 命令)
- BM13 determines whether a linked list is a palindrome
- virtual address space
- Black cats take you learn Makefile article 13: a Makefile collection compile problem
- Regular expression of shell programming and text processor
- 配电网络扩展规划:考虑使用概率性能源生产和消费概况的决策(Matlab代码实现)
- file IO-buffer
- 美味的石井饭
猜你喜欢
Shell 编程--Sed
Detailed installation steps and environment configuration of geemap
2022年8月10日:使用 ASP.NET Core 为初学者构建 Web 应用程序--使用 ASP.NET Core 创建 Web UI(没看懂需要再看一遍)
Nodes in the linked list are flipped in groups of k
常用代码扩展点设计方式
罗克韦尔AB PLC RSLogix5000中计数器指令使用方法介绍
从斐波那契 - 谈及动态规划 - 优化
VLAN huawei 三种模式
电力系统潮流计算(牛顿-拉夫逊法、高斯-赛德尔法、快速解耦法)(Matlab代码实现)
Research on multi-element N-k fault model of power system based on AC power flow (implemented by Matlab code) [Power System Fault]
随机推荐
What would happen if disconnecting during the process of TCP connection?
CIKM2022 | Sequence Recommendation Based on Bidirectional Transformers Contrastive Learning
Introduction to the use of counter instructions in Rockwell AB PLC RSLogix5000
Shell编程之条件语句(二)
JS中使用正则表达式g模式和非g模式的区别
测试4年感觉和1、2年时没什么不同?这和应届生有什么区别?
FPGA - Memory Resources of 7 Series FPGA Internal Structure -03- Built-in Error Correction Function
Qualcomm Platform Development Series Explanation (Application) Introduction to QCMAP Application Framework
谁是边缘计算服务的采购者?是这六个关键角色
Power system power flow calculation (Newton-Raphson method, Gauss-Seidel method, fast decoupling method) (Matlab code implementation)
【开源教程5】疯壳·开源编队无人机-飞控固件烧写
xshell (sed 命令)
服务——DHCP原理与配置
2022年8月10日:使用 ASP.NET Core 为初学者构建 Web 应用程序--使用 ASP.NET Core 创建 Web UI(没看懂需要再看一遍)
美味的佳肴
LeetCode每日两题01:反转字符串 (均1200道)方法:双指针
B站数据分析岗实习生面试记录
JS use regular expressions in g model and non g difference
“数据引擎”开启前装规模量产新赛道,「智协慧同」崭露头角
阿里云张新涛:支持沉浸式体验应用快速落地,阿里云云XR平台发布