Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
This project aims to provide a reusable pull to refresh widget for Android.
Java
branch: master

This branch is 68 commits behind johannilsson:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
pulltorefresh
pulltorefreshexample
.gitignore
README.md
android-pull-to-refresh.png

README.md

Pull To Refresh for Android

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

Screenshot

Note: This widget requires API Level 8 (Android 2.2).

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);
    }
}

Contributors

License

Copyright (c) 2011 Johan Nilsson

Licensed under the Apache License, Version 2.0

Something went wrong with that request. Please try again.