0% found this document useful (0 votes)
5 views4 pages

Lab 6 Clocks

The document discusses the use of android.widget.AnalogClock and android.widget.DigitalClock classes for displaying time in Android applications, noting that both have been deprecated in recent API levels. It provides an example of how to implement these clocks in an XML layout file and includes a simple MainActivity class. Additionally, it outlines tasks for developing applications that feature an analog and a digital clock, along with resources for further learning.

Uploaded by

abubakarthoughts
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Lab 6 Clocks

The document discusses the use of android.widget.AnalogClock and android.widget.DigitalClock classes for displaying time in Android applications, noting that both have been deprecated in recent API levels. It provides an example of how to implement these clocks in an XML layout file and includes a simple MainActivity class. Additionally, it outlines tasks for developing applications that feature an analog and a digital clock, along with resources for further learning.

Uploaded by

abubakarthoughts
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

ANDROID ANALOG CLOCK AND DIGITAL CLOCK

The android.widget.AnalogClock and android.widget.DigitalClock classes provides the


functionality to display analog and digital clocks.

Android analog and digital clocks are used to show time in android application.

Android AnalogClock is the subclass of View class.

Android DigitalClock is the subclass of TextView class. Since Android API level 17, it is
deprecated. You are recommended to use TextClock Instead.

The AnalogClock was deprecated in API level 23. This widget is no longer supported. Instead if
you want to use AnalogClock in your application you need to hard code. It does not appear in
API level 27 to drag from palette.

In android, you need to drag analog and digital clocks from the pallet to display analog and
digital clocks.

activity_main.xml

Now, drag the analog and digital clocks, now the xml file will look like this.

File: activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/an
droid"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="example.javatpoint.com.analogdigital.MainActivity">

<AnalogClock
android:id="@+id/analogClock1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginLeft="136dp"
android:layout_marginTop="296dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<DigitalClock
android:id="@+id/digitalClock1"
android:layout_width="wrap_content"

1 Android Application Development Manual


android:layout_height="wrap_content"
android:layout_below="@+id/analogClock1"
android:layout_centerHorizontal="true"
android:layout_marginLeft="176dp"
android:layout_marginTop="84dp"
android:text="DigitalClock"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>

Activity class

We have not write any code here.

File: MainActivity.java

package example.javatpoint.com.analogdigital;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

2 Android Application Development Manual


Output:

TASK 1:

Develop an android application to have an analog clock as the above example. [10]

TASK 2:

Develop an android application to display a digital clock on an activity. [10]

3 Android Application Development Manual


RESOURCES:

https://www.codingconnect.net/mobile-application-development-lab/
https://www.javatpoint.com/android-tutorial
https://www.tutorialspoint.com/android
https://developer.android.com/guide
Https://developer.Android.com/training/basics/firstapp/creating-
project
Https://www.raywenderlich.com/120177/beginning-Android-development-tutorial-
installingAndroid-studio https://www.youtube.com/playlist?
list=PLS1QulWo1RIbb1cYyzZpLFCKvdYV_yJ-E Https://www.udemy.com/java-
tutorial/
Https://www.w3schools.com/xml/
Http://www.Androidguys.com/

4 Android Application Development Manual

You might also like