これをチェックして:
Android: フラグメントで DatePickerDialog を取得する
それは簡単です:
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();
UpdateDisplay メソッド:
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