Initialize DatePickerDialog
private DatePickerDialog.OnDateSetListener date;
date = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
myCalendar.set(Calendar.YEAR, year);
myCalendar.set(Calendar.MONTH, monthOfYear);
myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
/////// Here You will get Selected Date from Calendar ///////
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd hh:mm:ss 'GMT'Z yyyy");
button.setText(dateFormat.format(cal.getTime()));
}
};
Введите этот код при нажатии кнопки
new DatePickerDialog(getActivity(), R.style.MyDialogTheme, date, myCalendar
.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
myCalendar.get(Calendar.DAY_OF_MONTH)).show();