This ActionBar-PullToRefresh is based on ActionBar-PullToRefresh by Chris Banes (website, github, twitter, linkedin).
The original version of ActionBar-PullToRefresh is made for Gradle (and Android Studio). However, importing that project into Eclipse (Android Development Tools) is a pain-in-the-a**! So I made this one, which can be imported directly into Eclipse and used right away.
The original project allows customizing of the PullToRefresh view via an XML file (See the Customisation page for more information.). However, many times, you would want to change a really small attribute such as color of the progress bar, or color of the text. In that case, the XML file becomes an overkill (and too much work for lazy people like me!).
So I added a few more methods to the Options
class. Here's how you can use it.
ActionBarPullToRefresh.from(getActivity())
.insertLayoutInto(viewGroup) // We need to insert the PullToRefreshLayout into the Fragment's ViewGroup
.theseChildrenArePullable(scrollView) // We need to mark the ListView and it's Empty View as pullable This is because they are not direct children of the
// ViewGroup
.options(Options.create()
.refreshingText("Fetching A lot of Stuff...")
.pullText("Pull me down!")
.releaseText("Let go of me!!!")
.titleTextColor(android.R.color.black)
.progressBarColor(android.R.color.holo_orange_light)
.headerBackgroundColor(android.R.color.holo_blue_light)
.progressBarStyle(Options.PROGRESS_BAR_STYLE_INSIDE) // or Options.PROGRESS_BAR_STYLE_OUTSIDE
.build())
.listener(new OnRefreshListener() { // We can now complete the setup as desired
// pulled to refresh
})
.setup(mPullToRefreshLayout);
There are two sample applications, the stock sample which uses the standard library and is therefore has a minSdkVersion
of 14. There is also a sample which uses the ActionBarSherlock extra so has a minSdkVersion
of 7.
ActionBar-PullToRefresh has in-built support for:
- AbsListView derivatives (ListView & GridView).
- ScrollView
- WebView
If the View you want to use is not listed above, you can easily add support in your own code by providing a ViewDelegate
. See the ViewDelegate
section below for more info.
See the Quick Start guides for more information on how to achieve a simple integration:
- Quick Start for API v14 and above.
- Quick Start: ActionBarCompat when using ActionBarCompat (appcompat).
- Quick Start: ActionBarSherlock when using ActionBarSherlock.
Then we are some advanced integration information:
- ListFragment when integrating the library with a ListFragment.
See the Customisation page for more information.
=======================