package app.test;
import android.app.Activity;
import android.os.Bundle;
import android.widget.DatePicker;
import android.widget.TextView;
import android.widget.TimePicker;
public class Test extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView dateDefault = (TextView)findViewById(R.id.dateDefault);
TextView timeDefault = (TextView)findViewById(R.id.timeDefault);
DatePicker dp = (DatePicker)this.findViewById(R.id.datePicker);
dateDefault.setText("Date defaulted to " + (dp.getMonth() + 1) + "/" +
dp.getDayOfMonth() + "/" + dp.getYear());
dp.init(2008, 11, 10, null);
TimePicker tp = (TimePicker)this.findViewById(R.id.timePicker);
java.util.Formatter timeF = new java.util.Formatter();
timeF.format("Time defaulted to %d:%02d", tp.getCurrentHour(),
tp.getCurrentMinute());
timeDefault.setText(timeF.toString());
tp.setIs24HourView(true);
tp.setCurrentHour(new Integer(10));
tp.setCurrentMinute(new Integer(10));
}
}
//main.xml
android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
android:layout_width="fill_parent" android:layout_height="wrap_content" />
android:layout_width="wrap_content" android:layout_height="wrap_content" />
android:layout_width="fill_parent" android:layout_height="wrap_content" />
android:layout_width="wrap_content" android:layout_height="wrap_content" />
android:layout_width="wrap_content" android:layout_height="wrap_content" />
android:layout_width="fill_parent" android:layout_height="wrap_content" />