开发者

SimpleAdapter - Adding New Data to List But on Which Thread?

I'm using a SimpleAdapter to populate a ListActivity. From the Google I/O video 'the world of ListView' it's made clear that the notifyDataSetChanged() method (for SimpleAdapter) MUST be called from the UI thread. But as regards updating the ArrayList in my ListActivity can that be safely done from any other thread?

Currently I do use a non-ui thread to update data in my ArrayList and then call notifyDataSetChanged() from the UI thread. This works fine and I can also dynamically update the SimpleAdapter too. However there is a certain aspect of my app that can cause it to crash and it happens when my ListActivity is in focus. I'm just currently exploring possible causes of the exception and it was something mentioned in the Google I/O video that left me unsure a开发者_C百科s to whether I can safely update my ArrayList from another thread.


According to the source code, adapted does not do any kind of synchronization on the underlying data list, so I assume it should only be changed from the UI thread.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜