What is the equivalent of setTimeOut() javascript to Android?

后端 未结 4 1421
被撕碎了的回忆
被撕碎了的回忆 2021-02-06 23:59

I need the equivalent code of setTimeOut(call function(),milliseconds); for android.

setTimeOut(call function(),milliseconds);
4条回答
  •  再見小時候
    2021-02-07 00:36

    This is the code that i used in my current project. I used TimerTask as Matt said. 60000 is the milisec. = 60 sec. i used it to refresh match scores.

    private void refreshTimer() {
            autoUpdate = new Timer();
            autoUpdate.schedule(new TimerTask() {
                @Override
                public void run() {
                    runOnUiThread(new Runnable() {
                        public void run() {
                            adapter = Score.getScoreListAdapter(getApplicationContext());
                            adapter.forceReload();
                            setListAdapter(adapter);
                        }
                    });
                }
            }, 0, 60000);
    

提交回复
热议问题