Android-Infinite-Scroll-Listview

This project aims to provide a reusable listview widget with infinite scrolling capability for asynchronous data loading and displaying.

Screenshot-1 Screenshot-2 Screenshot-3 Screenshot-4

Features

Support Android API Level 8+

Quick Setup

1. Include library

Manual:

2. Adapter class

public static abstract class NewPageListener {
    public abstract void onScrollNext();
    public abstract View getInfiniteScrollListView(int position, View convertView, ViewGroup parent);
}

@Override
protected void onScrollNext() {
    if (newPageListener != null) {
        newPageListener.onScrollNext();
    }
}

@Override
public View getInfiniteScrollListView(int position, View convertView, ViewGroup parent) {
    if (newPageListener != null) {
        return newPageListener.getInfiniteScrollListView(position, convertView, parent);
    }
    return convertView;
}

3. Activity class

  1. Loading Mode

    • Either the list view scrolls to the top or the bottom
    • Use setLoadingMode(LoadingMode loadingMode) to specify one of the following two loading modes
      enum LoadingMode {SCROLL_TO_TOP, SCROLL_TO_BOTTOM};
  2. Stop Position

    • When the data loading finishes, stop position determines weather the list view should automatically scroll up to the start of the list,
    • scroll down to the end of the list, or remains where it was
    • Use setStopPosition(StopPosition stopPosition) to specify one of the following three stop positions
      enum StopPosition {START_OF_LIST, END_OF_LIST, REMAIN_UNCHANGED}
  3. Use AsyncTask or IntentService to process your data, as shown in the demo code https://github.com/weixiao1984/Android-Infinite-Scroll-Listview/tree/master/demo