当前位置: 动力学知识库 > 问答 > 编程问答 >

performance - Android AlertDialogs

问题描述:

Is it every a good idea to build an AlertDialog on a background thread? Some dialogs can contain a lot of information, like long lists, which can take a while to load. Is it worth moving to a background thread to build?

网友答案:

You could gather the data in a background thread, but the dialog must be created in the main thread. In general, assume everything in the entire Android framework is meant to be called in the main thread, unless documented otherwise.

网友答案:

It's a good idea to do all expensive works outside the main thread in order to keep the UI reactive. When gathering displayed information can be time expensive then you should use a background thread.

After you've gathered all information then you definitely need to show the AlertDialog from within the main thread. No other hread then the main thread should do anything UI related.

分享给朋友:
您可能感兴趣的文章:
随机阅读: