Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

你也因为【Called attach on a child which is not detached: BaseViewHolder】崩溃了吗? #3721

Closed
longxuewei opened this issue Dec 4, 2022 · 0 comments

Comments

@longxuewei
Copy link

如果你也遇到了这个问题,那大概是刷新Adapter的时候没有加上 Adapter 的 Header 数量 以及 EmptyView 数量。所以出现这种情况只需要像这样:

mAdapter.notifyItemRangeChanged(positionStart + mAdapter.headerLayoutCount + if (mAdapter.hasEmptyView()) 1 else 0, itemCount)

mAdapter.notifyItemRangeInserted(positionStart + mAdapter.headerLayoutCount + if (mAdapter.hasEmptyView()) 1 else 0, itemCount)

mAdapter.notifyItemRangeRemoved(positionStart + mAdapter.headerLayoutCount + if (mAdapter.hasEmptyView()) 1 else 0, itemCount)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants