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

调用RecyclerView.Adapter的notifyDataSetChanged没反应的解决办法 #5

Open
lazy-ape opened this issue Jul 19, 2016 · 1 comment

Comments

@lazy-ape
Copy link

因为LoadMoreRecyclerView内部对adapter又进行了封装,所以在调用原来的adapter的notifyDataChange方法的时候界面并不会刷新,解决办法是:在LoadMoreRecyclerView.AutoLoadAdapter类的构造方法中添加对原adapter的监听,代码如下:

 public AutoLoadAdapter(RecyclerView.Adapter adapter) {
            mInternalAdapter = adapter;
            mIsHeaderEnable = false;
            mInternalAdapter.registerAdapterDataObserver(new AdapterDataObserver() {
                @Override
                public void onChanged() {
                     notifyDataSetChanged();
                }
            });
        }
@alicx
Copy link
Owner

alicx commented Nov 22, 2016

其实这个是通过开放在loadMoreRecyclerview. notifyMoreFinish方法进行数据刷新的,与正常使用的recyclerView直接通过adapter的notify 不同,是有点反人类了

最终我们项目中用是对这个版本进行了改造过的,目前github上的是初版,如果引入项目使用的话可能还是需要自己再改造过,这边其实是提供一个思路为目的的~

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