Skip to content

Latest commit

History

67 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

#RefreshListView

Simple Android ListView that enables pull to refresh as Twitter or Facebook apps ListView. Compatible with API 7 (Android 2.1).

RefreshListView Presentation

Usage

Please check out the example project.

If you need more technical information, you can refer to the javadoc I wrote in the RefreshListView class.

How to integrate it ?

Eclipse

Since RefreshListView is an apklib, you have to download it and import the refreshlistview_library folder in your Eclipse.

Then you need to go to Properties > Android in your project and add RefreshListView as a Library.

Maven

<dependency>
<groupId>com.github.jeremiemartinez</groupId>
<artifactId>refreshlistview</artifactId>
<type>apklib</type>
<version>1.4</version>
</dependency>

How to use it ?

Layout:

 <com.github.jeremiemartinez.refreshlistview.RefreshListView
android:id="@+id/list"android:layout_height="match_parent"android:layout_width="match_parent" />

Activity:

// onCreate method@OverridepublicvoidonCreate(BundlesavedInstanceState) {
[...]
// Add callback to RefreshListViewlist.setRefreshListener(newOnRefreshListener() {
@OverridepublicvoidonRefresh(RefreshListViewlistView) {
// Task to do while refreshingnewBackgroundTask().execute();
}
});
[...]
}
[...]
// Background AsyncTaskprivateclassBackgroundTaskextendsAsyncTask<Void, Void, String> {
@OverrideprotectedStringdoInBackground(Void... params) {
[...] // Do background taskreturnstring;
}
@OverrideprotectedvoidonPostExecute(StringnewApi) {
[...] // Update adapter// call on RefreshListView to hide header and notify the listview, refreshing is donelist.finishRefreshing();
}
}

Enable and use Update date/time:

Another feature implemented in this project, is to allow user to visualize the last update date and time. To do so, just use the following method:

list.setEnabledDate(true);

This method is overloaded and you can add a first date to start your list at loading as follow:

list.setEnabledDate(true, newDate());

Finally, you can also get the last update date thanks to the getter:

DatelastUpdate = list.getLastUpdateDate();

String resources and Localization:

If you want to change the default strings in the header, just add the following resources into your strings.xml file and change the values:

 <?xml version="1.0" encoding="utf-8"?>
<resources>
<stringname="refreshlistview_updating">Updating…</string>
<stringname="refreshlistview_release">Release to refresh…</string>
<stringname="refreshlistview_pulldown">Pull down to refresh…</string>
</resources>

Since, you can use the strings.xml file, you can also integrate localization. For instance, create a new folder according to Android documentation: in my case values-fr. Finally add the strings as before:

 <?xml version="1.0" encoding="utf-8"?>
<resources>
<stringname="refreshlistview_updating">Mise à jour…</string>
<stringname="refreshlistview_release">Relâcher pour actualiser…</string>
<stringname="refreshlistview_pulldown">Tirer pour actualiser…</string>
</resources>

Customizing styles

If you want to customize the style of the header, you can overload the following styles in your styles.xml, so your styles will be used instead of ours:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<stylename="refreshlistview_container">
[...]
</style>
<stylename="refreshlistview_arrow">
[...]
</style>
<stylename="refreshlistview_progress">
[...]
</style>
<stylename="refreshlistview_comment">
[...]
</style>
<stylename="refreshlistview_date">
[...]
</style>
<stylename="refreshlistview_header">
[...]
</style>
</resources>

Simple error handling:

To handle error in task, this project provides a simple method that will display a toast in case something went wrong in refresh task:

list.errorInRefresh("Something went wrong.");

Developed by

Licence

Copyright 2012-2013 - Jeremie Martinez (jeremiemartinez@gmail.com)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

Simple Android refresh ListView that enables pull to refresh as Twitter or Facebook apps ListView.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages