开发者

How to set up a timer that also checks for an event when running

I am developing a Question answer game. So a Timer is a must. I want the timer 开发者_如何学JAVAfor 30s. The timer should be running in the UI and when an onclick event like pressing a button occurs , that event should be triggered and the timer should be reset. If the timeout occurs it must display a timeout message and exit.

HELP! Thanks in advance


Well this is the best way to do that I guess a CountDownTimer

new CountDownTimer(Totalmiliseconds, interval) {

            @Override
            public void onTick(long intervalInMili) {
                tv.setText("second remaining - "+intervalInMili/1000);
            }

            @Override
            public void onFinish() {
                tv.setText("Done!!!!!!!!!!!!");
            }
        }.start();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜