Skip to content
This repository

This project aims to provide a reusable pull to refresh widget for Android.

#40
branch: scrollfix_for_…

This branch is 9 commits ahead and 14 commits behind master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 pulltorefresh
Octocat-spinner-32 pulltorefreshexample
Octocat-spinner-32 .gitignore Added .gitignore. January 09, 2011
Octocat-spinner-32 README.md Added Richard Guest as contributor, thank you. November 04, 2011
Octocat-spinner-32 android-pull-to-refresh.png Updated README. March 13, 2011
README.md

Pull To Refresh for Android

This project aims to provide a reusable pull to refresh widget for Android.

Screenshot

Repository at https://github.com/johannilsson/android-pulltorefresh.

Usage

Layout

<!--
  The PullToRefreshListView replaces a standard ListView widget.
-->
<com.markupartist.android.widget.PullToRefreshListView
    android:id="@+id/android:list"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    />

Activity

// Set a listener to be invoked when the list should be refreshed.
((PullToRefreshListView) getListView()).setOnRefreshListener(new OnRefreshListener() {
    @Override
    public void onRefresh() {
        // Do work to refresh the list here.
        new GetDataTask().execute();
    }
});

private class GetDataTask extends AsyncTask<Void, Void, String[]> {
    ...
    @Override
    protected void onPostExecute(String[] result) {
        mListItems.addFirst("Added after refresh...");
        // Call onRefreshComplete when the list has been refreshed.
        ((PullToRefreshListView) getListView()).onRefreshComplete();
        super.onPostExecute(result);
    }
}

Last Updated

It's possible to add a last updated time using the method setLastUpdated and onRefreshComplete. The text provided to these methods will be set below the Release to refresh text. Note that the time representation is not validated replaces the previous text, which means that it's possible and recommended to add a text similar to "Last Update: 15:23". This might be changed in future versions.

1.5 Support

To use the widget on 1.5 the necessary drawables needs to be copied to that projects drawable folder. The drawables needed by the widget can be found in the drawable-hdpi folder in the library project.

Contributors

Are you using this widget?

If you are using this widget please feel free to add your app to the wiki.

License

Copyright (c) 2011 Johan Nilsson

Licensed under the Apache License, Version 2.0

Something went wrong with that request. Please try again.