Skip to content

Instantly share code, notes, and snippets.

@januprasad
Last active February 17, 2020 15:12
Show Gist options
  • Save januprasad/98441b058578d4d190c6159272502249 to your computer and use it in GitHub Desktop.
Save januprasad/98441b058578d4d190c6159272502249 to your computer and use it in GitHub Desktop.
class TimePickerFragment : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
// Use the current time as the default values for the picker
val calendar: Calendar = Calendar.getInstance()
val hour = calendar.get(Calendar.HOUR)
val minute = calendar.get(Calendar.MINUTE)
/** Create a new instance of TimePickerDialog and return it
* && implement OnTimeSetListener on Activity.**/
return TimePickerDialog(
activity,
activity as TimePickerDialog.OnTimeSetListener,
hour,
minute,
true)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment