You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
先查看一个header的XRecyclerView(AActivity);再查看两个header的XRecyclerView(BActivity)就会触发 IllegalStateException: ViewHolder views must not be attached when created.
复现场景:
先查看一个header的XRecyclerView(AActivity);再查看两个header的XRecyclerView(BActivity)就会触发 IllegalStateException: ViewHolder views must not be attached when created.
经过分析发现
XRecyclerView.sHeaderTypes
为 被 static 修饰。而
addHeaderView
中 sHeaderTypes.add 和 mHeaderViews.add 肯定会由于多个列表的多次addHeaderView导致数据不同步。最后出现第一次加载列表
sHeaderTypes
已为 [10002]第二次加载列表
sHeaderTypes
为 [10002,10002,10003]且经过
XRecyclerView.WrapAdapter
中getItemViewType
->onCreateViewHolder
->getHeaderViewByType
会导致两次获取到同一个 headerView 。
The text was updated successfully, but these errors were encountered: