I have to change background image at every 30 seconds but i am not getting proper result
I have tried with thread and TimerTask. but no work.
I have port1, port2…etc images.
In TimerTask background is gone.
class Task1 extends TimerTask {
public void run() {
System.out.println("Checking a");
Random r = new Random();
int i = r.nextInt(3) + 1;
rl.setBackgroundResource(getResources().getIdentifier(
"port" + i, "drawable","com.samcom.breakingdowncd"));
}
}
Timer timerBackground = new Timer();
timerBackground.scheduleAtFixedRate(new Task1(), 0, 30000);
Its not working, any help will be appreciated.
Thanks
use this, it works
XML Code: