33

In the new gmail application (4.5) the refresh is done by "Pull-to-Refresh" action in the Actionbar:

enter image description here

enter image description here

Where can I find more information about that "Pull-to-Refresh"?

David
  • 37,109
  • 32
  • 120
  • 141
  • http://stackoverflow.com/questions/4583484/how-to-implement-android-pull-to-refresh – TactMayers Jun 07 '13 at 03:17
  • 3
    This link regarding the old way to do that... (2 years post). It's look like gmail does it in a new way. – David Jun 07 '13 at 03:32
  • Rather than a real "pull to refresh" it appears to be a simple gesture detector that is detecting a downward swipe. – Kuffs Jun 07 '13 at 06:18
  • For someone with the same question: http://www.tutecentral.com/android-pull-to-refresh/ – Adrian Mar 03 '14 at 08:30

1 Answers1

55

Chris Banes (the same guy that implemented the best pull to refresh component for android) also implemented the GMail like Pull To Refresh.

You can find it here: https://github.com/chrisbanes/ActionBar-PullToRefresh

Note that this project is still under development so the current API may change.

Update:

Both ActionBar-PullToRefresh and Android-PullToRefresh are deprecated. Standart way to implement a pull to refresh is using SwipeRefreshLayout of v4 support library.

Here is the required steps:

  • Create a root or sub layout with SwipeRefreshLayout and put a scrollable item in it.

    <android.support.v4.widget.SwipeRefreshLayout
        ...>
    
    <ListView
        .... />
    
    </android.support.v4.widget.SwipeRefreshLayout>
    
  • Add a refresh listener

    SwipeRefreshLayout srl = ...;
    srl.setOnRefreshListener(
        new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                ...
            }
        });
    

You can find a nice tutorial about it below:

SwipeRefreshLayout: How to use

Olcay Ertaş
  • 5,987
  • 8
  • 76
  • 112
micnoy
  • 3,926
  • 4
  • 24
  • 27
  • 1
    This project is no longer maintained, be aware. – Nizzy Oct 11 '13 at 16:26
  • 12
    https://github.com/chrisbanes/ActionBar-PullToRefresh looks still maintained (last commit sept 24). Did you mean Android-PullToRefresh? Because his docs do say that old project is no longer maintained. – qix Oct 16 '13 at 21:40
  • 1
    Also, this tutorial on ActionBar-PullToRefresh might be helpful: http://www.tutecentral.com/android-pull-to-refresh/ – sulai Mar 11 '14 at 15:39
  • 2
    https://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html – Chiara Jun 27 '14 at 14:04
  • Thank you Chiara! Funny how googling "Android pull to refresh" doesn't show that page – Gak2 Jul 07 '14 at 19:49