android - Set a backround timer to change the color randomly -
i have view , need change color of every x seconds.
i want decide when can start , stop timer.
this must done in background not block ui thread.
@baptistem, instead of using asynctask can use handler , runnable this,
private void startcolortimer() { mcolorhandler.postdelayed(colorrunnable, interval); timeron = true; } private handler mcolorhandler = new handler(); private runnable colorrunnable = new runnable() { @override public void run() { coloredtextview.settextcolor(getrancolor()); if (timeron) { mcolorhandler.postdelayed(this, interval); } } };
Comments
Post a Comment