Skip to content

Instantly share code, notes, and snippets.

@codinguser
Created June 15, 2012 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codinguser/2935425 to your computer and use it in GitHub Desktop.
Save codinguser/2935425 to your computer and use it in GitHub Desktop.
Show a DatePickerDialogFragment and handle the response from the dialog
@Override
public void onActivityCreated(Bundle savedInstanceState) {
mDateTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentTransaction ft = getFragmentManager().beginTransaction();
DialogFragment newFragment = new DatePickerDialogFragment(OnDateSetListenerFragment.this);
newFragment.show(ft, "date_dialog");
}
});
}
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
Calendar cal = new GregorianCalendar(year, monthOfYear, dayOfMonth);
mDateTextView.setText(DATE_FORMATTER.format(cal.getTime()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment