Scroll up does not work with SwipeRefreshLayout in Listview

后端 未结 10 1466
失恋的感觉
失恋的感觉 2020-12-01 10:36

I want to implement scroll to refresh functionality with a listView. Also there are other view elements in the same layout file which are displayed if the list is empty. Her

10条回答
  •  鱼传尺愫
    2020-12-01 11:09

    My Gridview Start Working with Swipefreshlayout

    gridView.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
    
            public void onScrollStateChanged(AbsListView view, int scrollState)
    
            {
    
            }
    
            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
                if (gridView.getChildAt(0) != null) {
                    mrefreshlayout.setEnabled(gridView.getFirstVisiblePosition() == 0 && gridView.getChildAt(0).getTop() == 0);
                }
    
             }
    
    
           });
    

    layout in xml

    
    
        
    
            
    
            
    
            
    
        
    
    
    
    

提交回复
热议问题