这很简单:
DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
mYear = year;
mMonth = monthOfYear;
mDay = dayOfMonth;
updateDisplay();
}
};
DatePickerDialog d = new DatePickerDialog(getActivity(),
R.style.MyThemee, mDateSetListener, mYear, mMonth, mDay);
d.show();
更新显示方法:
private void updateDisplay() {
GregorianCalendar c = new GregorianCalendar(mYear, mMonth, mDay);
SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM yyyy");
editDate.setText(sdf.format(c.getTime()));
sdf = new SimpleDateFormat("yyyy-MM-dd");
transDateString=sdf.format(c.getTime());
}// updateDisplay