Here is my code:
public class TestActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
start();
}
private void start() {
setContentView(R.layout.main);
LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);
Button button = new Button(this);
layout.addView(button);
button.getBackground().setColorFilter(new LightingColorFilter(0x00000000, 0x0000FF00)); // green
button.invalidate();
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
button.getBackground().setColorFilter(new LightingColorFilter(0x00000000, 0x000000FF)); // blue
button.invalidate();
}
}
This just displays a blue button after 3 seconds; it never shows it as green.
I think that if my brain worked properly, I could figure out the answer from one of these posts:
Why isn't view.invalidate immediately redrawing the screen in my android game
How to force a view to redraw immediately before the next line of code is executed