动态时间

new Thread(){

    @Override
    public void run() {
        while (true) {
            Date date = new Date();
            SimpleDateFormat s=new SimpleDateFormat("yyyy年MM月dd日   HH:mm:ss");
            String   format = s.format(date);
            handler.sendMessage(handler.obtainMessage(100,format));
            SystemClock.sleep(1000);
        }
    }

}.start();

private TextView mytime;
Handler handler=new Handler(){
    @Override
    public void handleMessage(Message msg) {
        String mtime= (String) msg.obj;
            mytime.setText(mtime);

    }
};



你可能感兴趣的:(动态时间)