开发者

Delay when starting Activities

I have a main activit开发者_JAVA技巧y (main menu / home screen) Most of my game runs on web calls. When I press a menu option it starts another activity. My activity calls some xml to build a listview in the onCreate... Is this causing the delays in launching activities from my main menu? Is there a method that will allow me load the activity, return the data to the display and then update the listview?

Any help is appreciated.

Thanks!


Building the listview in itself isn't going to slow things down much. What will slow things down is retrieving the data to populate the listview. If this is a time-consuming process, you should leave the list empty in onCreate and instead start an AsyncTask or other background thread to retrieve the data, wrap it in some kind of Adapter, and only then populate the listview (using a Handler).

In particular, if you are going out onto the web in onCreate, you will need to change the logic for your app to work under Honeycomb; the system will throw an exception if you attempt network activity on the UI thread.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜