Skip to content

Instantly share code, notes, and snippets.

@codeforfun-jp
Created December 23, 2023 05:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeforfun-jp/e46c7340fab549d0ac6c25c2f1b82652 to your computer and use it in GitHub Desktop.
Save codeforfun-jp/e46c7340fab549d0ac6c25c2f1b82652 to your computer and use it in GitHub Desktop.
How to Create Dialog Series Timepicker - Kotlin
class MyDialogFragment : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = activity?.let {
// デフォルトの時刻を用意
val c = Calendar.getInstance()
val hour = c[Calendar.HOUR_OF_DAY]
val minute = c[Calendar.MINUTE]
TimePickerDialog(it, null, hour, minute, true)
}
return dialog ?: throw IllegalStateException("アクティビティがNullです。")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment