Thursday, January 12, 2012

[android-developers] Button clicking colour change problem

Hi,

I am having problem with colour change of 2 buttons:

This is a simple code that I tested out on a device:

button1.setOnClickListener(new OnClickListener(){

@Override
public void onClick(View v) {
// TODO Auto-generated method stub

try {
Thread.sleep(15000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

});

button2.setOnClickListener(new OnClickListener(){

@Override
public void onClick(View v) {
// TODO Auto-generated method stub

try {
Thread.sleep(15000);

} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

});

When I click on button1 and (while this is executing) click on button2
and back to button1, both button1 and button2 appear coloured blue.
Why is this happening? The colouring of the 2 buttons should appear
sequentially because button clicking happens on the main thread, is it
not?

(Actually, I posted the same question on an earlier thread too but I
have not been able to figure out why this is happening)

Thank you,
B.Arunkumar

--
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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate