How to Build a Simple Clock for an Android in Eclipse

The Android software development kit, or SDK, includes an analog clock tag that creates a simple clock object in an Android application. The Android SDK requires you to code an app in the Java language, but you do not need to create any code. You create the analog clock using the app's XML file, which is the control file that builds and "draws" elements in your app.

Instructions

    • 1

      Open the Android Eclipse programming software and open the Android project you want to edit. Double-click the XML file for your app.

    • 2

      Add the "LinearLayout" tag container. This container holds the objects such as buttons, text and the clock, so you can display the objects in one screen. Add the following code:
      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"> </LinearLayout>

    • 3

      Add the clock tag to display the object in the layout container. Place the following code in the LinearLayout tag container:
      <AnalogClock android:id="@+id/myclock"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />

    • 4

      Click the "Save" button and click "Run" to execute the code in the Android emulator.

Related Searches:

References

Comments

Related Ads

Featured