2

I have this situation. I implemented endless scrolling with RecyclerView. Normally new items are suppose to load when there are only 5 items below the current scroll position but this is not so.

Rather As soon as the first set of items are loaded from the API, another is sent (without scrolling), received and parsed . After which yet another request is sent (still without scrolling) and parsed. This process continues (without scrolling) until the app is exited.

My RecyclerView

 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);
            }
        });
X09
  • 3,827
  • 10
  • 47
  • 92
  • Please try this: http://stackoverflow.com/questions/26543131/how-to-implement-endless-list-with-recyclerview – Michael Feb 28 '17 at 20:46

2 Answers2

2

I discovered that the problem is that the RecyclerView has a NestedScrollView as a parent. When I removed the NestedScrollView, this problem stopped.

X09
  • 3,827
  • 10
  • 47
  • 92
  • Thanks I spent 3 hour for this but u save my extra hours but I didn't get It why RecyclerView scroll endless without scroll in nestedScrollview can u explain ? I need recycle view inside scrollview. – Bhavin Patel May 09 '19 at 11:55
1

Turns out that this is a problem if you have a <ScrollView> in your layout (not only NestedScrollView).

Removing the ScrollView solved the problem for me!

Btw: This was only a problem when testing on older phones...

Tested with Samsung Galaxy S3 -> You must remove the ScrollView Tested with Samsung Galaxy S8 -> Works fine with ScrollView

Jules Dupont
  • 7,259
  • 7
  • 39
  • 39