【问题标题】:Endless RecyclerView Loading keeps loading without scrollingEndless RecyclerView Loading 不断加载而不滚动
【发布时间】:2017-02-28 20:27:31
【问题描述】:

我有这种情况。我实现了endless scrolling with RecyclerView。通常,当当前滚动位置下方只有 5 个项目时,假设会加载新项目,但事实并非如此。

而是一旦从 API 加载第一组项目,就会发送(无需滚动)、接收和解析另一组项目。之后发送另一个请求(仍然没有滚动)并解析。此过程将继续(不滚动),直到应用退出。

我的回收站视图

 mLayoutManager = new LinearLayoutManager(getActivity());
 recyclerView.setLayoutManager(mLayoutManager);
 recyclerView.setItemAnimator(new FadeInLeftAnimator());
 recyclerView.setNestedScrollingEnabled(false);
 adapter = new PostAdapter(mPostItemList, getActivity());
 recyclerView.setAdapter(adapter);

recyclerView.addOnScrollListener(new EndlessRecyclerViewScrollListener( mLayoutManager) {
            @Override
            public void onLoadMore(final int page, int totalItemsCount, RecyclerView view) {
                Log.w(TAG, "onLoadMore called");
                morePostsUrl = postUrl + "&page=" + page;
                getMorePostArray(morePostsUrl, true, false);
            }
        });

【问题讨论】:

标签: android android-recyclerview infinite-scroll


【解决方案1】:

我发现问题在于 RecyclerView 有一个 NestedScrollView 作为父级。当我移除 NestedScrollView 后,这个问题就停止了。

【讨论】:

  • 谢谢,我为此花了 3 个小时,但你节省了我额外的时间,但我没有明白为什么 RecyclerView 滚动无穷无尽而没有在 nestedScrollview 中滚动你能解释一下吗?我需要在滚动视图中回收视图。
【解决方案2】:

如果您的布局中有<ScrollView>(不仅是NestedScrollView),就会出现问题。

删除ScrollView 为我解决了问题!

顺便说一句:这只是在旧手机上测试时出现的问题......

使用三星 Galaxy S3 测试 -> 您必须删除 ScrollView 经三星 Galaxy S8 测试 -> 可与ScrollView 完美搭配

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-08
    • 1970-01-01
    • 2021-09-18
    • 2013-08-07
    • 2020-07-09
    • 2018-08-04
    • 1970-01-01
    相关资源
    最近更新 更多