32

Is there a way to use SwipeRefreshLayout to refresh ListView when it's pulled from bottom?

I created pull from top, but I would also need pull from bottom. There are many tutorials on how to create pull from top, but I couldn't find any tutorials for pull from bottom?

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
user3486440
  • 357
  • 1
  • 3
  • 4
  • 3
    Maybe because you were searching for the wrong thing? What you are describing is an [**endless ListView**](https://www.google.at/?q=endless%20listview#q=endless+listview) – Xaver Kapeller Jul 21 '14 at 14:13

5 Answers5

19

SwipeRefreshLayout from Android Support Library version 21 does not support pull from bottom. I have made modification SwipeRefreshLayoutBottom with is based on original SwipeRefreshLayout code. It is fully based on original Google code with just inversion of coordinates and overridden implementation of canChildScrollDown method. All modification are marked as TODO.

Bitbucker repository

Michael Peterson
  • 10,383
  • 3
  • 54
  • 51
AndreyICE
  • 3,574
  • 29
  • 27
  • 3
    Thanks AndreyICE. I ported your code to an Android Studio 1.2 project and created an aar library. The project also includes the gradle build. It's available at https://github.com/JohannBlake/SwipeRefreshLayoutBottom – Johann May 14 '15 at 13:25
  • This answer should be accepted! Thank you AndreyICE – jobernas Jun 16 '15 at 14:33
  • 1
    It should not. The asker is looking for both top and bottom. – Andrew G Aug 03 '15 at 05:31
  • 1
    also if you place SwipeRefreshLayoutBottom.java file inside android.support.v4.widget package in your project, the original package-private classes CircleImageView and MaterialProgressDrawable from support library will be available. So you won't have to keep a copy of these classes. – Dmide Jun 22 '16 at 08:23
17

Use this great library: OrangeGangsters SwipyRefreshLayout

So you can swipe both from top and bottom and supports API 9+.

Morteza Rastgoo
  • 6,772
  • 7
  • 40
  • 61
  • 1
    Great component. Just one issue though, the rotating arrow animation sometimes do not properly render and the arrow is not displayed. – Selçuk Cihan Jun 17 '16 at 11:15
  • You can create an issue in the repo, if you are sure about that problem – Morteza Rastgoo Jun 18 '16 at 06:28
  • This is cool layout but it's some bugs. Eg: pull up-to-bottom then pull bottom-to-up without lifting my finger, or sometimes refresh icon appears strange. – Na Pro Apr 20 '17 at 04:43
3

Library omadahealth/SwipyRefreshLayout must be the answer for your case.

Below Codes make your Recycler view pull up from bottom to refresh :

<com.omadahealth.github.swipyrefreshlayout.library.SwipyRefreshLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/refresh_layout"
    style="@style/View_MatchParent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    app:srl_direction="bottom"
    >

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerview"
        style="@style/View_MatchParent"
        android:layout_height="wrap_content"
        android:clipToPadding="true"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

</com.omadahealth.github.swipyrefreshlayout.library.SwipyRefreshLayout>
Huy Tower
  • 7,769
  • 16
  • 61
  • 86
0

I've encountered the same problem and I have solved it with a combination of swipeRefreshLayout and a touch event in my list. Here is the link:

https://stackoverflow.com/a/41701320/6144027

Community
  • 1
  • 1
Marie Amida
  • 556
  • 1
  • 5
  • 14
-6

No, you can't do that with SwipeRefreshLayout. You need to implement your own layout, which is not that hard.

Check this http://erikw.eu/open-source-android-pull-to-refresh-library/ and this http://www.oodlestechnologies.com/blogs/Implementing-Pull-to-refresh-(like-in-Facebook-mobile-app)-for-ANDROID-using-Titanium

ig343
  • 277
  • 1
  • 3
  • 17