Staggered Gridview (Recycleview) with load more functionality inside the NestedScrollView

后端 未结 1 339
别那么骄傲
别那么骄傲 2020-12-10 23:44

I want to implement the load more functionality inside my Staggered gridview. I have tried some lines of code for it like using addOnScrollListener but did not

相关标签:
1条回答
  • 2020-12-11 00:02

    Actually i was using the NestedScrollView which was the parent view of my Staggered recycleview .Therefore addOnScrollListener listener and setOnScrollChangeListener was not working in it..
    I have used setOnScrollChangeListener in a NestedScrollView and it worked fine. Check my below solution for it:-

    NestedScrollView myNestedScroll= (NestedScrollView) findViewById(R.id.myNestedScroll);
    
    myNestedScroll.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
    
            if (scrollY > oldScrollY) {
                Log.i(TAG, "Scroll DOWN");
            }
            if (scrollY < oldScrollY) {
                Log.i(TAG, "Scroll UP");
            }
    
            if (scrollY == 0) {
                Log.i(TAG, "TOP SCROLL");
            }
    
            if (scrollY == (v.getChildAt(0).getMeasuredHeight() - v.getMeasuredHeight())) {
                Log.i(TAG, "BOTTOM SCROLL");
            }
       }
    });
    
    0 讨论(0)
提交回复
热议问题