Giter Club home page Giter Club logo

android-simple-pull-to-refresh's Introduction

Android-Simple-Pull-to-Refresh

Using the style created by Chris Banes and recently implemented in the newest Gmail app, this is the easiest-to-implement Pull-to-Refresh possible.

instructions for use:

1: Add RefreshableListView.java to your own files source files.

2: Add RefreshableListView custom view to your layout file(possibly replacing a regular ListView).

<path.to.your.RefreshableListView
  android:id="@+id/RefreshList"
  style="@style/Widget.PullToRefresh.ProgressBar.Horizontal.Center"
  android:layout_width="match_parent"
  android:layout_height="match_parent" >
</path.to.your.RefreshableListView>

3: In the activity's onCreate method set the onListRefreshListener and the onListLoadMoreListener.

List.setOnListRefreshListener(this);
List.setOnListLoadMoreListener(this);

4: Treat the RefreshableListView as a regular list and set your adapter.

ListAdapter adapter = new someAdapter<someType>(...);
List.setAdapter(adapter);

5: (Optionally) You can adjust the threshold for drag length and the number of items from the bottom before a call to load more items;

List.setDragLength(500);
List.setDistanceFromBottom(10);

6: Make a call to finishRefresh() or finishLoadMore() to notify the list that the refresh or load is finished.

List.finishRefresh();
List.finishLoadingMore();

7: To interact with this list like the the stock ListView, simply access it.

List.getListView().setAdapter(adapter); //This also sets the adapter

To change the color of the loading bar, manipulate the PNG's Warning: changing the width might lead to some issue

I can safely assume that this works on all versions of android (unlike the original wutwut).

Created by Joe Dailey

This content is released under the MIT License.

Official Sample:

Get it on Google Play

Please feel free to submit pull requests!

Please also feel free to put a link to your project that uses this project at the bottom of this README!

android-simple-pull-to-refresh's People

Contributors

joedailey avatar

Watchers

James Cloos avatar  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.