Hello,
I have hundreds of CheckBox widgets in my layout and now I'm trying to
invert each of them, so if it was checked it won't be checked and vice
versa. Obviously such heavy work should be done in separate thread,
but the problem is that all the work actually happens the UI. Part of
the thread code:

for (int x = 0; x < list.getChildCount(); ++x)
{
  final WListRowTarget curRow = (WListRowTarget)list.getChildAt(x);
  curRow.post(new Runnable()
  {
    public void run()
    {
      try
      {
        curRow.getCheckBox().setChecked(!
curRow.getCheckBox().isChecked());
      }
      catch (Exception e) {}
    }
  });
}

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?

Thanks in advance,
Snowak

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

Reply via email to