How to set timer in android?

后端 未结 21 1249
渐次进展
渐次进展 2020-11-22 00:51

Can someone give a simple example of updating a textfield every second or so?

I want to make a flying ball and need to calculate/update the ball coordinates every se

21条回答
  •  野性不改
    2020-11-22 01:39

    This is some simple code for a timer:

    Timer timer = new Timer();
    TimerTask t = new TimerTask() {       
        @Override
        public void run() {
    
            System.out.println("1");
        }
    };
    timer.scheduleAtFixedRate(t,1000,1000);
    

提交回复
热议问题