Skip to content Skip to sidebar Skip to footer

Android Lollipop - Pull To Refresh

I am trying to implement pull-to-refresh in Android. I know there is SwipeRefreshLayout but with all the newly designed Google apps like Drive (see attached) for Lollipop, I have n

Solution 1:

This is SwipeRefreshLayout . Version 21 of the support library includes it replacing the old style.

Solution 2:

  1. Download the latest Lollipop SDK and Extras/Android support library
  2. Set Project's Build Target to Android 5.0 (otherwise support package can have errors with resources)
  3. Update your libs/android-support-v4.jar to 21st version
  4. Use android.support.v4.widget.SwipeRefreshLayout plus android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener

Detailed guide could be found here: http://antonioleiva.com/swiperefreshlayout/

Plus for ListView I recommend to read about canChildScrollUp() in the comments ;)

Solution 3:

I like this guide the best and its really easy to understand: https://www.bignerdranch.com/blog/implementing-swipe-to-refresh/

  1. Add the following to gradle:

    compile 'com.android.support:support-v4:22.2.0'

  2. Add the swipe to refresh to your layout - put in listview or recyclerview in the middle of the swiperefreshlayout:

    <ListViewandroid:id="@+id/activity_main_listview"android:layout_width="match_parent"android:layout_height="match_parent"
            ></ListView></android.support.v4.widget.SwipeRefreshLayout>
  3. Add in your code for the mainactivity:

    publicclassMainActivityextendsActivity {
    
    ListView mListView;
    SwipeRefreshLayout mSwipeRefreshLayout;
    Adapter mAdapter;
    
    @OverridepublicvoidonCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.acivity_main);
      SwipeRefreshLayout mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.activity_main_swipe_refresh_layout);
      mListView = findViewById(R.id.activity_main_list_view);
      mListView.setAdapter(newArrayAdapter<String>(){
      String[] fakeTweets = getResources().getStringArray(R.array.fake_tweets);
      mAdapter = newArrayAdapter<String>(this, android.R.layout.simple_list_item_1, fakeTweets)
      listView.setAdapter(mAdapter);
    });
    }
    

    }

  4. Don't forget to call mSwipeRefreshLayout.setRefreshing(false); once your refreshing ends.

Solution 4:

hi If you wan't to develop such a kind of Layout then please follow this url, i was used it it's an awesome.

https://github.com/stormzhang/SwipeRefreshLayoutDemo

Solution 5:

And the literal icon is in here:

http://material-design.storage.googleapis.com/publish/v_1/quantumexternal/0B08MbvYZK1iNZ19ldS1aNzdTQkU/material-design-icons-1.0.0.zip

source

Post a Comment for "Android Lollipop - Pull To Refresh"