Skip to content
Create a gist now

Instantly share code, notes, and snippets.

A simple fragment for displaying a date picker on Android. For use with the new Fragments API
import java.util.Calendar;
import android.os.Bundle;
public class DatePickerDialogFragment extends DialogFragment {
private OnDateSetListener mDateSetListener;
public DatePickerDialogFragment() {
// nothing to see here, move along
public DatePickerDialogFragment(OnDateSetListener callback) {
mDateSetListener = (OnDateSetListener) callback;
public Dialog onCreateDialog(Bundle savedInstanceState) {
Calendar cal = Calendar.getInstance();
return new DatePickerDialog(getActivity(),
mDateSetListener, cal.get(Calendar.YEAR),
cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.