In previous post i have explain you about Menu creation in Android and that post also got many likes. Thanks to all now I think its time to move on rather than creating a simple menus and buttons in android. Here in this post i am going to explain you that How to create a analog and digital clock in android. As if you are using Android handheld device then it is in system but let us see how it is programmed.
- For this post you should have basic knowledge of Android programming.
and better to read our two posts that contains some GUI creation and some syntax’s.
Lets begin to create a Clock in Android there is inbuilt function are there, You just have to adjust the layouts, position and background color.
So create a new Project and just simply copy and paste the code.
- for Analog clock:
- for Digital clock:
Save the project and run this. The output would be like this.
Now code explanation, As i said that android SDK offers us the syntax for creating the clock. The syntax is <AnalogClock attribute 1, attribute 2 …../ > for Analog clock and <DigitalClock attribute 1, attribute 2 …../ > for digital clock.
android:layout_width=”fill_parent” did the full screen mode for your program. Means it will cover full area of your screen.
android:layout_height=”wrap_content” is a command use to just put your content after the clock area.means not in between the screen of clock.
There were many other attributes too for clock.You can learn it from the Android SDK.
Thank you and happy programming.