Android: Update ListView Items every 1 minute

后端 未结 4 1530
长发绾君心
长发绾君心 2020-12-31 17:05

I have a Custom ListView in my application, containing an ImageView and 3-5 TextViews.

1 of the TextViews shows the time gap between the current time

4条回答
  •  佛祖请我去吃肉
    2020-12-31 17:52

    If you want repeat an action in the main thread in fractions of time you should use "schedule" method of the Time.class

    mHandler = new Handler();
    mTimer = new Timer();
    mTimer.schedule(new TimerTask() {
        @Override
        public void run() {
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    // run main thread code
                }
            });
        }
    }, DELAY_TIME, PERIOD_TIME);
    

提交回复
热议问题