Android: How do I display an updating clock in a TextView

前端 未结 6 972
时光说笑
时光说笑 2020-12-08 02:49

have a clock I want to display in a TextView.

I would have thought there was a few nice functions to do this, but I couldn\'t find anything. I ended up implementing

6条回答
  •  感情败类
    2020-12-08 03:41

    Check out the Chronometer and DigitalClock classes, which are extensions of the TextView class. They should automatically do what you're looking for. If you need some additional functionality, just take a look at the source code for those and make any changes you need.

    UPDATE:

    Since digital clock is deprecated in API 17, I would recommend to use Text Clock instead.

提交回复
热议问题