The UI won't update until after you leave the onClick method...

Either spawn a new thread or start a background service to do the waiting
for you...

On Nov 12, 2009 4:23 PM, "ElPollo Diablo" <hackas...@gmail.com> wrote:

I have a simple app that just changes the state of an image when you
press a button, waits 3 seconds, then changes back. The problem I am
seeing that that when it seems to sleep without changing the view to
show the state change, then when it is done, it changes back to the
original state, so to the user, it looks like nothing changed at all.
I may be way off in what I am thinking, but that seems to be the case,
as I can tell the sleep is working.

The code I have for the on click listener is:

press.setOnClickListener(new OnClickListener() {


                       public void onClick(View v) {
                               bButtonBlue.setSelected(true);

                               try {
                                       Thread.sleep(3000);
                               } catch (InterruptedException e) {
                                       e.printStackTrace();
                               }

                               bButtonBlue.setSelected(false);



                       }
       });
   }


Any ideas that could point me in the right direction would be much
appreciated.


Thank you

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

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

Reply via email to