Skip to content

Instantly share code, notes, and snippets.

@ishitcno1
Last active May 22, 2022 06:56
Show Gist options
  • Save ishitcno1/6109881 to your computer and use it in GitHub Desktop.
Save ishitcno1/6109881 to your computer and use it in GitHub Desktop.
android time picker fragment
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