How to set timer in android?

后端 未结 21 1347
渐次进展
渐次进展 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:30

    void method(boolean u,int max)
    {
        uu=u;
        maxi=max;
        if (uu==true)
        { 
            CountDownTimer uy = new CountDownTimer(maxi, 1000) 
      {
                public void onFinish()
                {
                    text.setText("Finish"); 
                }
    
                @Override
                public void onTick(long l) {
                    String currentTimeString=DateFormat.getTimeInstance().format(new Date());
                    text.setText(currentTimeString);
                }
            }.start();
        }
    
        else{text.setText("Stop ");
    }
    

提交回复
热议问题