- Android App Development Fundamentals for Beginners
- Guide to Install and Set up Android Studio
- Android | Starting with first app/android project
- Android | Running your first Android app
Analog and digital clocks are used for display the time in android application.
- Analog clock: Analog clock is a subclass of View class. It represents a circular clock. Around the circle, numbers 1 to 12 appear to represent the hour and two hands are used to show instant of the time- shorter one for the hour and longer is for minutes.
- Digital clock: Digital clock is subclass of TextView Class and uses numbers to display the time in “HH:MM” format.
In this Article, a simple android application is built to display the Analog clock and Digital clock.
How to create a Android Analog clock and Digital clock?
This example will help to develop an Android App that displays an Analog clock and a Digital clock according to the example shown above:
Below are the steps for Creating the Analog and Digital clock Android Application:
- Step1: Firstly create a new Android Application. This will create an XML file “activity_main.xml” and a Java File “MainActivity.Java”. Please refer the pre-requisites to learn more about this step.
- Step2: Open “activity_main.xml” file and add following widgets in a Relative Layout:
- An Analog clock
- A Digital clock
This will make the UI of the Application. There is no need for assignment of IDs as these widgets will display the time by themselves.
- Step3: Leave the Java file as it is.
- Step4: Now Run the app. Both clocks are displayed on the screen.
The complete code of MainActivity.java and activity_main.xml of Analog Digital clock is given below:
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Java Applet | How to display an Analog Clock
- Java Applet | How to display a Digital Clock
- ThaiBuddhistDate now(Clock) method in Java with Example
- HijrahDate now(Clock) method in Java with Example
- How to draw a Clock using StillClock in Java
- Clock system() Method in Java with Examples
- Clock tick() Method in Java with Examples
- Clock tickSeconds() method in Java with Examples
- Clock systemDefaultZone() Method in Java with Examples
- Clock systemUTC() Method in Java with Examples
- Java 8 Clock offset() method with Examples
- Java 8 Clock fixed() method with Examples
- LocalTime now(clock) method in Java with Examples
- YearMonth now(clock) method in Java with Examples
- Java 8 Clock millis() Method with Examples
- HijrahChronology dateNow(Clock) method in Java with Example
- Java 8 Clock equals() Method with Examples
- MinguoChronology dateNow(Clock) method in Java with Example
- Java 8 Clock getZone() method with Examples
- MonthDay now(Clock) method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.