Android dynamic loading list view onScrollListener issues

后端 未结 3 2046
太阳男子
太阳男子 2020-12-21 03:52

I have implemented a list view, every user scroll to bottom screen, it auto add new data to list view Once the scroll has completed, onScroll() call for every new item that

3条回答
  •  余生分开走
    2020-12-21 04:49

        lv_best.setOnScrollListener(new OnScrollListener() {
                    @Override
                    public void onScrollStateChanged(AbsListView view, int scrollState) {
                        switch (scrollState) {
                        case OnScrollListener.SCROLL_STATE_IDLE:
                                             // when list scrolling stops
    
                                            manipulateWithVisibleViews(view);
    
                            break;
                        case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
                            break;
                        case OnScrollListener.SCROLL_STATE_FLING:
                            break;
                        }
                    }
    
                    @Override
                    public void onScroll(AbsListView view, int firstVisibleItem,
                            int visibleItemCount, int totalItemCount) { 
                    }
                });
    
    private void manipulateWithVisibleViews(AbsListView view){
            int count = view.getChildCount(); // visible views count
            int lastVisibleItemPosition = view.getLastVisiblePosition();
    
            for (int i = 0; i < count; i++) {
                View convertView = view.getChildAt(i);
                // update views
                }
            }
    
    }
    

提交回复
热议问题