SoFunction
Updated on 2025-04-09

Android dynamic display time

How can we achieve dynamic time? Maybe you don’t understand it if you just entered the industry. If you don’t understand, please read the code (the code is the best teacher). laughing out loud

public void onCreate(Bundle savedInstanceState) { 
    (savedInstanceState); 
    setContentView(); 
    textView=(TextView) findViewById(); 
      handler = new Handler() { 
        public void handleMessage(Message msg) { 
          ((String)); 
        } 
      }; 
    new Thread(this).start(); 
  } 
  @Override 
  public void run() { 
    // TODO Auto-generated method stub 
    try { 
      while(true){ 
        SimpleDateFormat sdf=new SimpleDateFormat("yyyyy MM month dd day HH:mm:ss"); 
        String str=(new Date()); 
        ((100,str)); 
        (1000); 
      } 
    } catch (InterruptedException e) { 
      // TODO Auto-generated catch block 
      (); 
    } 
  } 

As can be seen from the above code, this is a multi-threaded. After obtaining the system time in real time, the data will be updated.