How To Change A Java Timer's Interval
I'm working on an android Tetris game. And an IllegalStateException occurred when executing timer.scheduleAtFixedRate (task, 0L, milliseconds); in public void setTimerInterval (in
Solution 1:
Handlerhandler=newHandler();
handler.post(newRunnable() {
@Overridepublicvoidrun() {
// do the task here
handler.postDelayed(this, milliseconds); // set time here to refresh textView
}
});
Make the milliseconds
global and change that, maybe that would be a better solution.
Post a Comment for "How To Change A Java Timer's Interval"