android - Set TextView to display integers that change for a certain length of time -
i add textview layout holds integer value , continues change it's value length of time. example, textview change value 10 seconds , stops. how can this?
you may want countdowntimer. code this:
countdowntimer mycountdown = new countdowntimer(10000, 1000){ public void ontick(long millisuntilfinished) { mytextview.settext(string.valueof(millisuntilfinished / 10)); } public void onfinish() { mytextview.settext("done!"); } }.start();
this create timer runs 10 seconds , updates textview every second. important thing note parameters in milliseconds, not seconds. first parameter (10,000 in example) represents duration of timer. second parameter (1,000) determines how many milliseconds occur between each call ontick()
.
Comments
Post a Comment