-2

Currently I am using Digital Clock. It is taking the mobile time format 12 hr or 24 hr. But for my requirement I thought of using TextClock now to always display the time in 12 hr format.

There is set parameter available in TextClock to set the time format. The xml parameter is format12Hour. And one more thing is TextClock is supported from andriod api 17. What will happen for the api less than 17.

Please kindly share me your option to use the Textclock for my case.

M Vignesh
  • 1,586
  • 2
  • 18
  • 55

1 Answers1

6

DigitalClock is for API-16 and below, TextClock is the new widget for API-17 and above:

DigitalClock

This class was deprecated in API level 17. It is recommended you use TextClock instead.

You should simply use 2 XMLs to support both:

layout/yourlayout.xml with DigitalClock widget and layout-v17/yourlayout.xml with TextClock widget.

shkschneider
  • 17,833
  • 13
  • 59
  • 112
  • Yes clear and Always I want to display 12 hour format. Ho to do that? – M Vignesh May 04 '15 at 11:11
  • That is another question. And *everything* is clearly explained in the official documentation https://developer.android.com/reference/android/widget/TextClock.html – shkschneider May 04 '15 at 12:31
  • I tried by setting the 12 hr format. But still it is displayed in 24 hr format which is same as phone time format. Any idea? – M Vignesh May 04 '15 at 12:44
  • I'm sorry but you should open another question for that. This one seems answered to me (feel free to validate). – shkschneider May 04 '15 at 12:45