当前位置:网站首页>Recyclerview 批量更新View:notifyItemRangeInserted、notifyItemRangeRemoved、notifyItemRangeChanged
Recyclerview 批量更新View:notifyItemRangeInserted、notifyItemRangeRemoved、notifyItemRangeChanged
2022-04-23 06:07:00 【张海龙_China】
如果recyclerview 绑定了数据,假设数据有变化,我们通常是:
notifyDataSetChanged 或者:notifyItemChanged(int position)
但如果数据过多notifyDataSetChanged 肯定会消耗一些性能,如果是一次更新多个notifyItemChanged()不行,这个时候用到recyclerview 有一个批量更新的方法notifyItemRangeChanged();
Recyclerview的局部刷新功能:
从指定位置开始刷新指定个item,notifyItemRangeChanged(int,int);
增、删、改的局部刷新:
增:
notifyItemRangeInserted(int startPosition,int itemcount)
startPosition:起始位置,插入数据的位置。
itemcount:数据个数。
删:
notifyItemRangeRemoved(int startPosition,int itemcount)
参数和“增”是相同的,但有个注意的问题点:
调用此方法后需要进行对后面的所有数据进行调用
notifyItemRangeChanged(startPosition,allCount-startPosition);
不然会出现位置异常。(具体原因后期再研究)
改:
直接用notifyItemRangeChanged(int startPosition,int itemcount);
版权声明
本文为[张海龙_China]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Jason_HD/article/details/123486855
边栏推荐
- 实习做了啥
- 专用窗口函数rank, dense_rank, row_number
- Django::Did you install mysqlclient?
- RAC环境alert日志报错Drop transient type: SYSTP2JW0acnAurDgU1sBqMBryw==的排查
- Oracle redo log产生量大的查找思路与案例
- Abnormal record-17
- PG SQL截取字符串到指定字符位置
- Chaos takes you to the chaos project quickly
- ORACLE环境遇到的ORA-600 [qkacon:FJswrwo]
- Research on alertmanager repeated / missing alarm phenomenon and two key parameters_ Wait and group_ Interpretation of interval
猜你喜欢
统一任务分发调度执行框架
实习做了啥
Dolphinscheduler调度sql任务建表时The query did not generate a result set异常解决
Static interface method calls are not supported at language level ‘5‘ 异常解决
Encapsulate a set of project network request framework from 0
Implementation of multi tenant read and write in Prometheus cortex
取消远程依赖,用本地依赖
10g数据库使用大内存主机时不能启动的问题
Information:2021/9/29 10:01 - Build completed with 1 error and 0 warnings in 11s 30ms Error异常处理
useReducer基本用法
随机推荐
接口幂等性问题
Prometheus monitoring method and index interpretation of influxdb
oracle杀死正在执行的sql
useReducer基本用法
qs. In the stringify interface, the input parameter is converted into a & connected string (with the application / x-www-form-urlencoded request header)
统一任务分发调度执行框架
Chaos帶你快速上手混沌工程
oracle清除sql的缓存
Using Prom label proxy to implement label based multi tenant reading of Prometheus thanos
Exception record-6
OSS云存储管理实践(体验有礼)
开篇:双指针仪表盘的识别
JVM basics you should know
How does VirtualBox modify the IP network segment assigned to the virtual machine in the "network address translation (NAT)" network mode
Exception record-9
项目,怎么打包
Exception record-5
iTOP4412内核反复重启
Information:2021/9/29 10:01 - Build completed with 1 error and 0 warnings in 11s 30ms Error异常处理
组件化学习(1)思想及实现方式