S
S
SerS2016-05-29 19:41:15
Java
SerS, 2016-05-29 19:41:15

how to make a clock on android

While not strong in programming, please tell me how to make a clock so that it goes?
Tried Date and through SimpleDateFormat displayed on TextView. But how to make them update themselves? It is impossible to cram into the cycle, the Application does not start .. Who knows how to do this, tell me please .. And they will need to be run in a separate thread, do I understand correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2016-05-29
@NeiroNx

There are many options. It is possible through Handler

private Handler TimeHandler = new Handler() {
        @Override
        public void handleMessage(Message message) {
           //Обновляем часы
           TimeHandler.sendEmptyMessageDelayed(0,1000L);//1 sec update
        }
    };

you need to start it manually for the first time: TimeHandler.sendEmptyMessageDelayed(0,10L);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question