Repeat a task with a time delay?

后端 未结 12 1431
小蘑菇
小蘑菇 2020-11-22 02:14

I have a variable in my code say it is \"status\".

I want to display some text in the application depending on this variable value. This has to be done with a speci

12条回答
  •  自闭症患者
    2020-11-22 02:45

    Timer works fine. Here, I use Timer to search text after 1.5s and update UI. Hope that helps.

    private Timer _timer = new Timer();
    
    _timer.schedule(new TimerTask() {
        @Override
        public void run() {
            // use runOnUiThread(Runnable action)
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    search();
                }
            });
        }
    }, timeInterval);
    

提交回复
热议问题