Android: Fetching an XML from a web service: Threads
Fetching an XML from a web service in background and displaying a progress bar in front while the xml is being downloaded in A开发者_StackOverflow社区ndroid
Have a look at:
http://developer.android.com/resources/articles/painless-threading.html
and:
http://developer.android.com/reference/android/os/AsyncTask.html
For info on how to perform work in the background.
In short:
Subclass AsyncTask and override doInBackground(Params... params). In that method you should do the communication with the server and download the xml. You can call publishProgress(Progress... values) to have the UI thread run the method onProgressUpdate(Progress... values) in your AsyncTask. In that method you can define how to update the progressbar.
Cheers // Emil H
精彩评论