Android - Want app to perform tasks every second

后端 未结 4 557
-上瘾入骨i
-上瘾入骨i 2020-12-17 23:28

I\'m trying to get my countdown app to perform its function of updating my current time and date TextView and fire off its MyOnItemSelectedListener every second so that the

4条回答
  •  醉话见心
    2020-12-18 00:04

    To run it on the main thread:

            new Timer().schedule(new TimerTask() {
            @Override
            public void run() {
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        yourMethodOnTheMainThread();
                    }
                });
            }
        },0,10000);
    

提交回复
热议问题