views:

415

answers:

1

I am trying to update the ListView with periodic updates taken from an HTTP response. Now, I am thinking that because this is very specific to my application, I can get away by using a background thread and then updating the ListView using the magic UI thread. The last time I tried this, I had to remove the entire adapter of the ListView and then fill it up again so it worked. But this time, what I am trying to do is a more "smooth" scrolling ListView... something like a scrolling ticker... Is there a different approach to achieve this?

+2  A: 

That depends on the Adapter. If you are using an ArrayAdapter, you can call add() on the ArrayAdapter itself to add items on the fly.

CommonsWare
Thank You. So the problem is, I am able to get it to update but the listview doesn't seem to get updated unless I scroll through it after which it starts getting elements from the newly filled adapter. Any suggestions?
Legend
Visit http://commonsware.com/Android, scroll down, and click on the Source Code link to download a ZIP file. In there, look for the Threads/Asyncer project. There, you will find an example of a ListView being updated from a background thread. Those updates are displayed in real time (at least the scrollbar is shrinking, showing that the ListView knows about the new rows). See if that helps.
CommonsWare
Thanks for help... I will look into that... From what you described, I think that is what I am looking for...
Legend