Rocel
Rocel

Reputation: 1037

Can I create UI outside main thread (UI Thread)?

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?

Upvotes: 1

Views: 888

Answers (1)

Raghav Sood
Raghav Sood

Reputation: 82533

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.

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.

Upvotes: 2

Related Questions