Last active
May 22, 2022 06:56
-
-
Save ishitcno1/6109881 to your computer and use it in GitHub Desktop.
android time 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 TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener { | |
@Override | |
public Dialog onCreateDialog(Bundle savedInstanceState) { | |
int hourOfDay = calendar.get(Calendar.HOUR_OF_DAY); | |
int minute = calendar.get(Calendar.MINUTE); | |
return new TimePickerDialog(getActivity(), this, hourOfDay, minute, true); | |
} | |
@Override | |
public void onTimeSet(TimePicker view, int hourOfDay, int minute) { | |
calendar.set(Calendar.HOUR_OF_DAY, hourOfDay); | |
calendar.set(Calendar.MINUTE, minute); | |
//do some stuff | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment