当前位置:网站首页>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
边栏推荐
猜你喜欢

iTOP4412 HDMI显示(4.4.4_r1)

qs. In the stringify interface, the input parameter is converted into a & connected string (with the application / x-www-form-urlencoded request header)

组件化学习(3)ARouter中的Path和Group注解

useReducer基本用法

Build an OSS based image sharing website - polite feedback

Problems related to Prometheus cortex using block storage

Try catch cannot catch asynchronous errors

Explore how @ modelandview can forward data and pages through the source code

实习做了啥

10g数据库使用大内存主机时不能启动的问题
随机推荐
Android面试计网面经大全【持续更新中。。。】
iTOP4412无法显示开机动画(4.0.3_r1)
AVD Pixel_2_API_24 is already running.If that is not the case, delete the files at C:\Users\admi
oracle数据库将多个列的查询结果集合并到一行中
Exception record-5
RAC环境中openssh版本对SSH互信创建的影响
统一任务分发调度执行框架
补补网络缺口
Itop4412 kernel restarts repeatedly
Prometheus monitoring method and index interpretation of influxdb
Oracle索引状态查询与索引重建
Prometheus thanos Quick Guide
oracle库恢复数据
个人博客网站搭建
PG SQL截取字符串到指定字符位置
Typical application scenarios of alicloud log service SLS
实习做了啥
RAC环境alert日志报错Drop transient type: SYSTP2JW0acnAurDgU1sBqMBryw==的排查
error 403 In most cases, you or one of your dependencies are requesting解决
org.xml.sax.SAXParseException; lineNumber: 141; columnNumber: 252; cvc-complex-type.2.4.a: 发现了以元素 ‘b