| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This project aims to provide a reusable Pull to Refresh widget for Android. It is originally (loosely) based on Johan Nilsson's Library (mainly for graphics, strings and animations), and has been vastly improved since then.
Repository at https://github.com/chrisbanes/Android-PullToRefresh.
<!--
The PullToRefreshListView replaces a standard ListView widget.
The ID CAN NOT be @+id/android:list
-->
<com.handmark.pulltorefresh.library.PullToRefreshListView
android:id="@+id/pull_to_refresh_listview"
android:layout_height="fill_parent"
android:layout_width="fill_parent" />It can also be styled using XML, such as in the sample ExpandableListView Sample:
<com.handmark.pulltorefresh.library.PullToRefreshExpandableListView
xmlns:ptr="http://schemas.android.com/apk/res/YOUR_APP_PACKAGE_NAME"
android:id="@+id/pull_refresh_expandable_list"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
ptr:ptrAdapterViewBackground="@android:color/white"
ptr:ptrHeaderBackground="@android:color/darker_gray"
ptr:ptrHeaderTextColor="@android:color/white" />// Set a listener to be invoked when the list should be refreshed.
PullToRefreshListView pullToRefreshView = (PullToRefreshListView) findViewById(R.id.pull_to_refresh_listview);
pullToRefreshView.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) {
// Call onRefreshComplete when the list has been refreshed.
pullToRefreshView.onRefreshComplete();
super.onPostExecute(result);
}
}By default this library is set to Pull Down to Refresh, but if you instead to Pull Up to Refresh you can do so via XML:
<com.handmark.pulltorefresh.library.PullToRefreshListView
xmlns:ptr="http://schemas.android.com/apk/res/YOUR_APP_PACKAGE_NAME"
android:id="@+id/pull_refresh_list"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
ptr:ptrMode="pullUpFromBottom" />You can even set the View to enable both Pulling Up and Pulling Down using the new 'both' setting. For example:
<com.handmark.pulltorefresh.library.PullToRefreshListView
xmlns:ptr="http://schemas.android.com/apk/res/YOUR_APP_PACKAGE_NAME"
android:id="@+id/pull_refresh_list"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
ptr:ptrMode="both" />I will gladly accept pull requests for fixes and feature enhancements but please do them in the dev branch. The master branch is for the latest stable code, dev is where I try things out before releasing them as stable. Any pull requests that are against master from now on will be closed asking for you to do another pull against dev.
Licensed under the Apache License, Version 2.0
| Back | FazBrowse Home | New Git URL |