Display Current Time in Android using TextClock
http://www.viralandroid.com/2015/11/display-current-time-in-android-using-textclock.html
In this tutorial, you will learn to display the current time using TextClock widget in android application. This widget is introduced in API level 17. You can specify the format pattern 12 hour time format or 24 hour time format and also specify the time zone.
In this TextClock example, I have used two text clocks to display current time in android application, one for default format and another for 12 hour format.
Related:
Android Time Picker Example
Get Current Time in Android Programmatically
Android Date Picker Example
For more about TextClock, visit android developer site.
Now, run your text clock android application to display current time which will look like output given below.
Output:
In this TextClock example, I have used two text clocks to display current time in android application, one for default format and another for 12 hour format.
Related:
Android Time Picker Example
Get Current Time in Android Programmatically
Android Date Picker Example
Android TextClock: How to Display Current Time in Android
XML Layout File
res/layout/android_text_clock_example.xmlJava Activity File
src/AndroidTextClock.javaStrings.xml File
res/values/strings.xmlFor more about TextClock, visit android developer site.
Now, run your text clock android application to display current time which will look like output given below.
Output:
Android TextClock |