2

Possible Duplicate:
How to implement Android Pull-to-Refresh

I have implemented pull to refresh in my app which works fine in 2.2, but in 2.0 it doesn't.

I couldn't find the method 'smoothScrollBy()' in 2.0.

Can anyone please give me the solution for this issue or any other alternative? How can I acheive pull to refresh functionality like in iphone?

Thanks..

Community
  • 1
  • 1
RATTLESNAKE
  • 3,220
  • 2
  • 18
  • 22

3 Answers3

5

You could also take a look to Johan Nilsson's android-pulltorefresh library:

https://github.com/johannilsson/android-pulltorefresh

It provides an out-of-the-box "pull to refresh" widget that replace the basic Android ListView.

lethargicpanda
  • 732
  • 9
  • 18
2

smoothScrollBy was introduced in API version 8, so it is not available in other versions. (You can see what API version a method is available in on the far right hand side of the detailed API, like here).

I'm not sure what refreshing your app has to do with smoothScrollBy though. If you have a ListView with an adapter, you can just update the contents of the adapter and call notifyDataSetChanged()

casperOne
  • 70,959
  • 17
  • 175
  • 239
Cheryl Simon
  • 44,959
  • 14
  • 91
  • 82
  • He's talking about using a special list header item at the top that triggers a content refresh when it becomes fully visible. In such a scheme usually you would want to smoothly scroll the list back to real content to reset after the refresh has been triggered or after a fling ends. The official Twitter app does this. – adamp Jan 13 '11 at 18:19
  • notifyDataSetChanged cannot be used in this case. As adamp said, he needs refresh list on the pull like twitter app. You answered wrong. – Umakant Patil Feb 08 '11 at 07:29
1

I've also implemented a robust, open source, easy to use and highly customizable PullToRefresh library for Android. You can replace your ListView with the PullToRefreshListView as described in the documentation on the project page.

https://github.com/erikwt/PullToRefresh-ListView

Erik
  • 5,611
  • 8
  • 26
  • 32
  • If you have another widget on top of the listview with pulltorefresh, on refreshing the listview header goes on top of the widget above. – Prakash Nadar Mar 21 '12 at 23:39