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

前端 未结 27 2842
灰色年华
灰色年华 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条回答
  •  庸人自扰
    2020-11-29 20:15

    It took me two days but could not get around this, in the end, I had to disable the item prefetch.

    When setting the layout manager you can simply call

    mGridLayoutManager.setItemPrefetchEnabled(false);

    It made the error go away for me. Hope it will be useful for someone.

提交回复
热议问题