How to add Swipe-to-Refresh To your app

suggest change

Make sure the following dependency is added to your app’s build.gradle file under dependencies:

compile 'com.android.support:support-core-ui:24.2.0'

Then add the SwipeRefreshLayout in your layout:

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

     <!-- place your view here -->       

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

Finally implement the SwipeRefreshLayout.OnRefreshListener listener.

mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
mSwipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
    @Override
    public void onRefresh() {
         // your code
    }
});

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents