Friday, August 19, 2011

[android-developers] Re: Updating UI from second thread

Nobody tells you to freeze the UI thread. Dig into source code, see
how Handlers, Looper and MessageQueue works and you'll get an idea how
you can implement everything on UI thread without having it "frozen".
It's all about that.

On Aug 19, 6:35 am, Snowak <psno...@gmail.com> wrote:
> What a wonderful answer. It's a great idea to answer everything with
> "you don't know what you're doing" and tell me to do it using worst
> possible method. Yeah, let's freeze the UI thread. It's gonna be cool.
>
> On 17 Sie, 23:17, Mark Murphy <mmur...@commonsware.com> wrote:
>
>
>
>
>
>
>
> > On Wed, Aug 17, 2011 at 12:44 PM, Snowak <psno...@gmail.com> wrote:
> > > I have hundreds of CheckBox widgets in my layout
>
> > That is unlikely to be a good idea.
>
> > > Obviously such heavy work should be done in separate thread,
>
> > Not really.
>
> > > The only thing that this thread actually can do is looping through the
> > > list and posting the Runnable for every found checkbox. The problem is
> > > that all those Runnables arrive in the UI thread almost at the same
> > > time, thus they're all executed at once... The application behaves
> > > exactly like I would run the above code in the UI thread - everything
> > > freezes. A possible solution is sleeping for some miliseconds after
> > > each checkbox so the Runnable can be executed and the UI will have
> > > time to process the events... but it's more like a hack.
>
> > > How can I solve this problem?
>
> > Redesign your UI to not have "hundreds of CheckBox widgets" at once.
> > Or, update them on the main application thread and hope for the best.
>
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> > _Android Programming Tutorials_ Version 3.9 Available!

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment