In this tutorial, it shows on how to create a digital clock in android.
How it works?
- Open main xml under the res/layout folder
<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"
/>
<DigitalClock
android:id="@+id/dclock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="50dp"
android:layout_gravity="center"
/>
</LinearLayout>
2. Open DigitalClockActivity.java under the src folder
package
icodefree.digitalclock.android;
import
android.app.Activity;
import
android.os.Bundle;
import
android.widget.DigitalClock;
public class
DigitalClockActivity extends Activity {
/** Called when the activity is first
created. */
DigitalClock dc;
public void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
dc=(DigitalClock)findViewById(R.id.dclock);
}
}
If you like to get the source code, download it here for FREE.
If you like to get the source code, download it here for FREE.