Android Tutorial

(avery) #1
Android Tutorial 197

Using the AnalogClock

The AnalogClock control is a dial-based clock with a basic clock face
with two hands, one for the minute and one for the hour. It
updates automatically as each minute passes. The image of the
clock scales appropriately with the size of its View. Here is an
example of an XML layout resource definition for an AnalogClock
control:

<AnalogClock
android:id=”@+id/AnalogClock01”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content” />


The AnalogClock control’s clock face is simple. However you can set
its minute and hour hands. You can also set the clock face to
specific drawable resources, if you want to jazz it up. Neither of
these clock controls accepts a different time or a static time to
display. They can show only the current time in the current time
zone of the device, so they are not particularly useful.

Providing Users with Options and Context Menus

You need to be aware of two special application menus for use
within your Android applications: the options menu and the
context menu.

Enabling the Options Menu

The Android SDK provides a method for users to bring up a menu
by pressing the menu key from within the application. You can use
options menus within your application to bring up help, to navigate,
Free download pdf