Last active
December 20, 2015 09:40
-
-
Save ishitcno1/6109868 to your computer and use it in GitHub Desktop.
android date picker fragment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { | |
@Override | |
public Dialog onCreateDialog(Bundle savedInstanceState) { | |
int year = calendar.get(Calendar.YEAR); | |
int month = calendar.get(Calendar.MONTH); | |
int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH); | |
return new DatePickerDialog(getActivity(), this, year, month, dayOfMonth); | |
} | |
@Override | |
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { | |
calendar.set(Calendar.YEAR, year); | |
calendar.set(Calendar.MONTH, monthOfYear); | |
calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth); | |
//do some stuff | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment