(Android) Why won't invalidate() update my buttons immediately?
- by frustrated user
I have read several forums and examples on using invalidate() in order to update views immediately but I still do not understand why what I am doing will not work. The code below uses image buttons defined by "red", "blue", "green", and "yellow". I set a 1 second delay between each time I try and change a button's appearance. Please someone tell me what i'm doing wrong.
private void showPattern() {
if (correct == true) {
for (int k = 0; k < temp_basket.length; k++) {
if (temp_basket[k] == 0) {
red.setPressed(true);
red.invalidate();
final Handler handler = new Handler();
Timer t = new Timer();
t.schedule(new TimerTask() {
public void run() {
handler.post(new Runnable() {
public void run() {
red.setPressed(false);
red.invalidate();
}
});
}
}, 1000);
There are 3 more or these blocks after this one that are blue, green, and yellow.