Skip to content

Instantly share code, notes, and snippets.

@jezinka
Last active Jul 18, 2017
Embed
What would you like to do?
public void showDatePickerDialog(final View v) {
Calendar cal = Calendar.getInstance();
DatePickerDialog datePickerDialog = new DatePickerDialog(v.getContext(),
android.R.style.Theme_Holo_Light_Dialog_MinWidth,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
Calendar calendarInstance = Calendar.getInstance();
calendarInstance.set(year, monthOfYear, dayOfMonth);
((EditText) v).setText(df.format(calendarInstance.getTime()));
}
}, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DATE));
datePickerDialog.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment