//ActivityDatePicker.java
package android.ActivityUI;
import android.app.Activity;
import android.os.Bundle;
import android.widget.DatePicker;
public class ActivityDatePicker extends Activity{
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.date_picker);
setTitle("DatePicker");
DatePicker dp = (DatePicker) findViewById(R.id.datePicker);
dp.init(2011,9, 10, null);
}
}
//data_picker.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">
<DatePicker
android:id="@+id/datePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</DatePicker>
</LinearLayout>
//ActivityTimePicker.java
package android.ActivityUI;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TimePicker;
public class ActivityTimePicker extends Activity{
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.time_picker);
setTitle("TimePicker");
TimePicker tp = (TimePicker)findViewById(R.id.timePicker);
tp.setIs24HourView(true);
}
}
//time_picker.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TimePicker
android:id="@+id/timePicker"
android:text="TimePicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TimePicker>
</LinearLayout>