I'm not looking for the easy solution (although that would be nice),
but I will be more than happy with someone pointing me in the right
direction so I can figure it out.

I can set the button colors, but I can't change them.  Well, I can,
but not the way I would like to:

using this line of code in onCreate:

redButton.setBackgroundColor(Color.RED);

sure enough, the button starts as red.

Later, in another method in the same activity and thread, I try to
change the color once again:

redButton.setBackgroundColor(Color.BLACK);

next, I tell it to draw again:

redButton.invalidate();

finally I introduce a delay to let the UI update and allow the user to
see the color change:

long t = System.currentTimeMillis();
t = t + 100;
while ( System.currentTimeMillis() < t ) { ; }  // crude, but I think
it's effective

I want the color of the button to return to the previous color
automatically, so I do this next:

redButton.setBackgroundColor(Color.RED);
redButton.invalidate();

The delay happens, but the color change does not.  Or does it, and I
just don't see it (because it happens too fast)?

When I remove the final two lines of code that change the color back
to red, the button does turn black.

So, I think this may have to do with threads, but I'm not sure.  Any
advice would be greatly appreciated.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to