by

Pull To Refresh for Android

Finally! At last I got my Alloy Pull-To-Refresh widget to work on Android, and with that probably also on other OS (BlackBerry, MobileWeb). How something so easy can be so hard..

Pull to Refresh

On iOS

The iOS version uses the headerPullView property of the TableView it attaches to. This view is shown when the uses drags the table down while it is already scrolled to the top. Unfortunately, this view is iOS-only.

On Android

The newly released Android version uses the headerView property. It is similar to headerPullView but always shows. To simulate the iOS behavior I set the top position of the TableView to a negative value corresponding to the height of the headerView. Then when a swipe gesture is detected while the TableView is already scrolled to the top, the top of the TableView is set back to 0.

Infinite Scroll

Another widget recently updated for Android is Infinite Scroll (formerly Dynamic Scroll). On both iOS and Android it uses the footerView, but like the headerView on Android this view can’t be removed or resized once it is added. I couldn’t find any workaround for this, so to maintain platfom parity the view now remains visible on iOS as well, displaying a message all content has been loaded.

ListView

The headerView, footerView and pullView properties are not available for the new ListView at the moment, but will be in 3.2.0. I’ll update both widgets as soon as I have time to play with the nightly builds.