RecyclerView crashes when “scrapped or attached views may not be recycled”

前端 未结 27 2894
灰色年华
灰色年华 2020-11-29 19:50

I\'m using a simple implementation of RecyclerView taken from the Android website using a StaggeredGridLayoutManager and I keep getting this error

27条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-29 20:06

    I've had to deal with this crash also and in my case it had nothing to do with android:animateLayoutChanges.

    The RecyclerView we were building had more than one type of views in it and some were having EditTexts in them. After a while we pinned the issue to being focus related. This bug happens while recycling EditTexts and one of them is focused.

    Naturally we tried clearing the focus when new data is being bound to a recycled view but that didn't work until android:focusableInTouchMode="true" is set on RecycleView. Actually that is the only change that was needed in the end for this issue to go away.

提交回复
热议问题