Code example for AbsListView

Methods: getChildCount, getCount, getFirstVisiblePosition

0
    public void onScrollStateChanged(final AbsListView view,
                                     final int scrollState) {
        switch (scrollState) {
        case SCROLL_STATE_IDLE:
            this.mAdapter.setScrolling(false);
            final int first = view.getFirstVisiblePosition();
            final int count = view.getChildCount();
            final int totalItemCount = view.getCount();
 
            if (first + count == totalItemCount && !this.mLast) {
                this.loadNextPage();
            } else { 
                this.mAdapter.notifyDataSetChanged();
            } 
            break; 
        case SCROLL_STATE_FLING:
            this.mAdapter.setScrolling(true);
            break; 
        case SCROLL_STATE_TOUCH_SCROLL:
            this.mAdapter.setScrolling(true);
            break;