Animated Pull To Refresh Layout - Android Studio Tutorial (2021)

Animated Pull To Refresh Layout - Android Studio Tutorial (2021)

 


Introduction : 

We are going to learn how to implement a user friendly swipe refresh in android studio.

  • First, we have to implement some lines of code in build.gradle(app).

'com.github.recruit-lifestyle:WaveSwipeRefreshLayout:1.6'

  • Then we'll implement layout in xml.
<jp.co.recruit_lifestyle.android.widget.WaveSwipeRefreshLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/main_swipe">

      //Write your code here

</jp.co.recruit_lifestyle.android.widget.WaveSwipeRefreshLayout>

  • Here comes the java part ..
mWaveSwipeRefreshLayout = (WaveSwipeRefreshLayout) findViewById(R.id.main_swipe);
mWaveSwipeRefreshLayout.setOnRefreshListener(new WaveSwipeRefreshLayout.OnRefreshListener() {
  @Override public void onRefresh() {
    // Do work to refresh the list here.
    new Task().execute();
  }
});

private class Task extends AsyncTask<Void, Void, String[]> {
  ...
  @Override protected void onPostExecute(String[] result) {
    // Call setRefreshing(false) when the list has been refreshed.
    mWaveSwipeRefreshLayout.setRefreshing(false);
    super.onPostExecute(result);
  }
}


That's all feel free to comment your doubts below..

Post a Comment

0 Comments