Android Analog Clock

 

In this tutorial, it shows on how to create a analog clock in android.
How it works?
1. Open main xml under the res/layout folder

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Time Now"
        android:layout_gravity="center"
        android:textColor="#F98748"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <AnalogClock
        android:id="@+id/analogClock"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center" />

</LinearLayout>
 2. Open AnalogClockActivity.java under the src folder
package icodefree.analogclock.android;

import android.app.Activity;
import android.os.Bundle;
import android.widget.AnalogClock;

public class AnalogClockActivity extends Activity {
    /** Called when the activity is first created. */
  
    AnalogClock ac;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        ac=(AnalogClock)findViewById(R.id.analogClock);
    }
}