New Pull-to-Refresh Library

Hi everyone,

Over the past week or so I’ve been working on a new implementation of the Pull-to-Refresh widget for Android, as part of improvements for FriendCaster. The new library is based off Johan Nilsson’s library, but has changed a lot since then.

The way that the previous library achieves Pull-To-Refresh is via ListView HeaderViews which has certain drawbacks:

  • Hard to show/hide the HeaderView when you don’t have enough items in your list
  • Have to use ScrollListener, which is slow.
  • Only works with ListView’s.
Our new library is different because it’s actually a LinearLayout wrapper around an AdapterView, which hides/shows the Refreshing View. The end result has several improvements over the previous library:
  • Can be used with all AdapterViews (ListView, GridView, etc, etc).
  • Animated Scrolling for all relevant Android OS versions (tested on v1.6+).
  • Works properly when you don’t have many items in your AdapterView (no more ‘Tap to Refresh’).
  • Works just as well as the Official Twitter App’s Pull-to-Refresh in my opinion.
You can find the new Library here: https://github.com/chrisbanes/Android-PullToRefresh