Posting those changes as a bunch if runnables into the UI thread is probably
causing a slowdown by itself.

As those checkboxes change state, the UI starts updating itself to reflect
their new appearance. Just when it's done with the first bunch of changes,
more runnables arrive, causing the UI to be laid out and redrawn again. This
repeats until all the runnables have been received and processed (or at
least I think it quite possible - sorry, don't have a similar layout to try
this with).

I also don't see how a hundred checkboxes can all be visible on the sceen at
the same time. And if they're not, then using some sort of adapter view
pattern should help update just the visible ones, deferring the rest until
they are scrolled into view or become visible by some other means.

--
Kostya Vasilyev
20.08.2011 0:52 пользователь "Paul Turchenko" <paul.turche...@gmail.com>
написал:
> 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+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to