I want to display 3 colors in my activity screen layout without any user interaction with a time interval. for example for each 3 seconds one color should be displayed in my activity screen.
I tried with Thread.sleep(); It is showing the last color only after a long sleep.
screenLayout=(LinearLayout)findViewById(R.id.screenLayout);
screenLayout.setBackgroundColor(Color.RED);
Log.e("","RED COLOR DISPLAYING..");
try {
Thread.sleep(7000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
screenLayout.setBackgroundColor(Color.GREEN);
Log.e("","GREEN COLOR DISPLAYING..");
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
screenLayout.setBackgroundColor(Color.BLUE);
but it didnt work. Could any one please tell me the way to do this.
you can do like this way using Handler and Runnable object
This is the example only but you can implement from this example