Reputation: 72533
Hello I would like to implement pull to refresh in my Android App. But there are just Implimentations for ListViews. I would like to refresh TextViews because the Text in these TextViews is parsd from an XML(online) so whenever I change the XML and you would pull to refresh, the TextViews would be updated. Is it possible to impliment that. Are there similar projects or gits?
Thanks!
Edit: So basically I just want the pull to refresh animation.
Upvotes: 2
Views: 2122
Reputation: 45493
I would definitely take a look at Chris Banes' implementation of pull-to-refresh. His code does not only include this interaction style for ListView
, but also GridView
and WebView
.
Especially the latter will be of interest in your case, since it's an example implementation of pull-to-refresh for a view that does not use an adapter for its content. If you look at the source code, you'll see that every concrete pull-to-refreh view in Banes' project extends from a generic PullToRefreshBase
, which contains most of the logic for animation and refreshing. The benefit of having that base class is that doing the same thing for any other type of view, e.g. a TextView
, should be pretty straightforward.
The only drawback of this approach is that the implementation is a wrapper for other views, meaning you'll have write a couple of extra lines to get the actual view. So it's not a full drop-in replacement. However, its functionality and features far exceed that little inconvenience. :)
Upvotes: 8