现象
常在路边走,哪有不湿鞋。
这不就有一个需求,让做一个列表的单条目刷新,多简单的一个需求啊,简简单单的CV之后,代码就敲完了,然后手贱了一小下,做了个自测,然后,悲剧就这么出现了。
具体需求我已经记不住了,这里模拟一下类似的情况,自定义一个ViewHolder,其中有一个参数count,用于记录当前ViewHolder刷新了多少次,然后通过TextView展示出来即可。
布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:viewBindingIgnore="true">
<EditText
android:id="@+id/index"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="onlyNotify"
android:text="无Payload刷新" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="notifyAll"
android:text="全局刷新" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="notifyWithPayloads"
android:text="有Payload刷新" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/loop_rv"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
tools:context=".ui.loop.LoopActivity">
</androidx.recyclerview.widget.Re
500




被折叠的 条评论
为什么被折叠?



