views:

28

answers:

1

Hello,

I have multiple ListActivity(s) with a custom ArrayAdapter. I have to load an XML file from the Web, and the user moves to a new activity by selecting a list item.

What is best practice for:

  1. Displaying a loading indication to the user.
  2. Threading the networking stuff so that the user can cancel the loading of the data if need be / move to the previous activity.

Example/source code would be greatly appreciated - I've used http://www.helloandroid.com/tutorials/newsdroid-rss-reader as an introduction, however it doesn't display a loading indication.

Thanks

A: 

Hi,

I think its a better idea retrieving the xml file with a thread in the backend because it can very frustrating to wait while the an application freezes to download data.

if you send the reference to your activity to the thread you can use to this method to display the data on the ui thread and even show or hide and progress indicator:

runOnUiThread(Runnable action)

check out this link, in there i found a great example on threading, to download images dynamically and even save a cache to make it faster... (example code included)

Link

hope this helps

mklfarha