Harshad
Harshad

Reputation: 129

Android Swipe Up to Refresh ListView

I have to implement android swipe up to refresh listview. I got sample code from here. But in this code it is swipe down to refresh listview. And I want it in swipe up to refresh listview. If anyone know answer then please explain or suggest me link from where I can understand from beginning. Thank You.

Upvotes: 2

Views: 9030

Answers (3)

Ramees
Ramees

Reputation: 76

You can use SwipeRefreshLayout,The layout you need to refresh should give inside this layout.

<android.support.v4.widget.SwipeRefreshLayout
  android:id="@+id/sw_refresh"
  android:layout_width="match_parent" 
  android:layout_height="wrap_content">

  <!--layout which should be refreshed should come here-->

      <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"></ListView>

       </android.support.v4.widget.SwipeRefreshLayout>

   </RelativeLayout>

You can see the complete implementation at Android swipe to refresh listview layout

Upvotes: 0

slama007
slama007

Reputation: 1293

Previously we used to implement a custom swipe view to detect the swipe down. But android made our day easier by introducing SwipeRefreshLayout in android.support.v4 to detect the vertical swipe on any view.

Below link shows show step by step procedure

http://www.androidhive.info/2015/05/android-swipe-down-to-refresh-listview-tutorial/

Upvotes: -2

Amarjit
Amarjit

Reputation: 4357

Please Use

Link Library for scrolling bottom/Up by setting direction.

You can use other SO links too

SwipeRefreshLayout - Pull From Bottom

Upvotes: 4

Related Questions