Giter Site home page Giter Site logo

neil-orzzh / android-infinite-scroll-listview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aizazzaidee/android-infinite-scroll-listview

0.0 1.0 0.0 326 KB

Listview widget with infinite scrolling capability, scroll up to top or down to bottom to load next page, and you can choose to scroll to top/bottom automatically or make it stay where it was after data is loaded.

License: Apache License 2.0

Java 100.00%

android-infinite-scroll-listview's Introduction

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

  • Users scroll up to top or down to bottom of the listview widget to load more data
  • Upon data loading finishes, listview widget automatically scrolls to the top/bottom, or stays where it was
  • Self-explanatory demo code

Support Android API Level 8+

Quick Setup

1. Include library

Manual:

2. Adapter class

  • Create an adapter which extends InfiniteScrollListAdapter
  • Inside the adapter create an interface or abstract class so later actions in the view can be propagated to the customized adapter
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};
  1. 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}
  1. 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

android-infinite-scroll-listview's People

Contributors

aizazzaidee avatar weixiao1984 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.