CymChad / BaseRecyclerViewAdapterHelper

BRVAH:Powerful and flexible RecyclerAdapter
http://www.recyclerview.org/
MIT License
24.31k stars 5.16k forks source link

Called attach on a child which is not detached: BaseViewHolder #3646

Open andyhaha opened 2 years ago

andyhaha commented 2 years ago

version:3.0.7 Fatal Exception: java.lang.IllegalArgumentException Called attach on a child which is not detached: BaseViewHolder{de9678c position=1 id=-1, oldPos=-1, pLpos:-1 not recyclable(1)} androidx.recyclerview.widget.RecyclerView{

andyhaha commented 2 years ago

有人提供一下帮助吗 help!

Qiang11 commented 1 year ago

recyclerView系统bug默认动画导致的,去掉默认动画就可以了

ZeQiangFang commented 11 months ago

或许新版已经修复,但用旧版懒得升级的,就需要注意下使用方式。

在添加了 header 的情况下,notify item 时,其位置应该是:

notifyItemChanged(index + headerLayoutCount) 其中 index 为需要更新的条目位置, headerLayoutCount 是可以在 adapter 中直接获取到的一个方法,写法为 kotlin 所以显示看着是变量。