Skip to content

Instantly share code, notes, and snippets.

@jezinka
Last active July 18, 2017 07:54
Show Gist options
  • Select an option

  • Save jezinka/8f35a838d0581d4f1b0ce8f2325f4918 to your computer and use it in GitHub Desktop.

Select an option

Save jezinka/8f35a838d0581d4f1b0ce8f2325f4918 to your computer and use it in GitHub Desktop.
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