I want to make an image be visibile for 60 ms and then be invisible, then I want another image to do the same.. and so on. I don't think I'm using the Timer right.. because when I run the app both images turn on at the same time and don't disappear when I press the button that uses this function.
Here's some sample code..
timer.schedule(new TimerTask()
{
@Override
public void run()
{
LED_1.setVisibility(View.VISIBLE);
// LED_1 is an ImageView
}
}, 60);
LED_1.setVisibility(View.INVISIBLE);
timer2.schedule(new TimerTask()
{
@Override
public void run()
{
LED_2.setVisibility(View.VISIBLE);
// LED_2 is an ImageView
}
}, 60);
LED_2.setVisibility(View.INVISIBLE);
Is there another alternative? I've tried examples like.. Android app How to delay your Service start on phone boot
and
http://www.roseindia.net/java/beginners/DelayExample.shtml
But it's not doing what I want..
Anything I'm doing wrong? Or is there an alternative way that 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);