I want to make the image visible for 60 ms and then be invisible, then I want the other image to do the same .. and so on. I donβt think that I am using Timer correctly .. because when I launch the application, both images turn on at the same time and do not disappear when I press the button using this function.
Here is a sample code.
timer.schedule(new TimerTask() { @Override public void run() { LED_1.setVisibility(View.VISIBLE);
Is there any other alternative? I tried examples like .. Android application How to delay the start of a service when the phone boots
and
http://www.roseindia.net/java/beginners/DelayExample.shtml
But that does not do what I want.
Anything I'm doing wrong? Or is there an alternative way I can do this?
Thanks.
-Faul
For Good.Dima ..
int delayRate = 60; final Runnable LED_1_On = new Runnable() { public void run() { LED_1.setVisibility(View.VISIBLE); handler.postDelayed(this, delayRate); } }; handler.postDelayed(LED_1_On, delayRate); final Runnable LED_2_On = new Runnable() { public void run() { LED_1.setVisibility(View.INVISIBLE); LED_2.setVisibility(View.VISIBLE); handler3.postDelayed(this, delayRate); } }; handler.postDelayed(LED_2_On, delayRate);
source share