Android AnalogClock and DigitalClock example

main.xml


<?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:orientation="vertical" >
 
    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Analog Clock"
        android:textAppearance="?android:attr/textAppearanceLarge" />
 
    <AnalogClock
        android:id="@+id/analogClock1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
 
    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Digital Clock"
        android:textAppearance="?android:attr/textAppearanceLarge" />
 
    <DigitalClock
        android:id="@+id/digitalClock1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="DigitalClock" />
 
</LinearLayout>


AnalogClockDigitalClockDemoActivity.java


package com.cjp.analogdigitalclock;


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


public class AnalogClockDigitalClockDemoActivity extends Activity {
 
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
 
AnalogClock ac = (AnalogClock) findViewById(R.id.analogClock1);
//what can i do with AnalogClock?
 
DigitalClock dc = (DigitalClock) findViewById(R.id.digitalClock1);
//what can i do with DigitalClock also? for display only
 
}
 
}


你可能感兴趣的:(android,layout,Class,encoding)