I have a method which refreshes a list view by re-setting the adapter of the list view. The adapter downloads a thumbnail image for each list item when it is set.
I want to run this method called refreshListView() on a new thread so that the images get downloaded asynchronously but i’m aware that i can’t update the UI on a separate thread.
What are the alternative ways to do this?
Thanks in advance.
You could use an AsyncTask ( http://developer.android.com/reference/android/os/AsyncTask.html) or a Loader ( http://developer.android.com/guide/topics/fundamentals/loaders.html). I recommend using a loader as it seems to be always easier. Both were (among other things) designed for exactly this type of problem.
In order to use the Loader on any target platform less than 3.0, please refer to http://developer.android.com/sdk/compatibility-library.html.