开发者

Android: Possible to create ProgressDialog without using Thread?

I have a ListActivity which loads data from a database during onCreate(). Is it possible to show a ProgressDialog without using a thread? Using a thread seems to disable the ListActivity's onListItemClick method. But maybe I'm doing something wrong. I'm also doing a lazy load of items in my listactivity, so the list loads 10开发者_StackOverflow items at a time using onScroll.

Any help or direction is appreciated:)


ProgressDialog is always running on UI thread, so you don't need any additional thread to create it. Threads are used for long-running operations, that can last for more than 5 seconds, cause blocking the UI thread will trigger the ANR error. If you're sure your loading process won't ever take 5 seconds, you can do it right on UI thread with showing a ProgressDialog (or a ProgressBar, which I feel is better, cause it doesn't prevent your users from working with your application). If the loading can last for some longer, you should think about implementing a separate thread to handle this process. Hope this helps.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜