我可以创建主线程(UI线程)之外的用户界面? [英] Can I create UI outside main thread (UI Thread)?

查看:147
本文介绍了我可以创建主线程(UI线程)之外的用户界面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的UI是很好的理由(计算数以百计的看法测量)pretty长生成(约20秒)。
我(觉得呢?)在主线程创建它们,然后我运行一个progressdialog使用户等待。
虽然,主线程已经被创建其他计算的过载。
我能那么主线程之外创建UI虽然我得到几个观点测量?

my UI is pretty long to generate (about 20 seconds) for good reasons (calculating measurements of hundreds of views). I (think?) have to create them in the main thread, and then I run a progressdialog to make the user wait. Though, the main thread is already overloaded by the creation of the other calculations. Could I then create UI outside the main thread though I have to get measurements of several views?

推荐答案

虽然有些人说,他们已经得到它的工作,无论是的 Dianne和罗曼说的,你不应该这样做了讨论,整个UI树是单线程的。他们说,这是不能保证的工作,应尽量避免。

While some people say that they have got it to work, both Dianne and Romain say that you should not do this in a discussion, as the entire UI tree is single threaded. They say that it is not guaranteed to work, and should be avoided.

我不能想出中,你会需要几百个实例,并在同一时间绘制视图中的任何场景。也许你需要使用一个ListView,或者实现某种延迟加载在你的应用程序。

I can't come up with any scenario in which you'd need hundreds of Views instantiated and drawn at the same time. Perhaps you need to use a ListView, or implement some kind of lazy loading in your app.

这篇关于我可以创建主线程(UI线程)之外的用户界面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆