Added in API level 1

TimePickerDialog


open class TimePickerDialog : AlertDialog, DialogInterface.OnClickListener, TimePicker.OnTimeChangedListener
kotlin.Any
   ↳ android.app.Dialog
   ↳ android.app.AlertDialog
   ↳ android.app.TimePickerDialog

A dialog that prompts the user for the time of day using a TimePicker.

See the Pickers guide.

Summary

Nested classes
abstract

The callback interface used to indicate the user is done filling in the time (e.g. they clicked on the 'OK' button).

Inherited constants
Public constructors
TimePickerDialog(context: Context!, listener: TimePickerDialog.OnTimeSetListener!, hourOfDay: Int, minute: Int, is24HourView: Boolean)

Creates a new time picker dialog.

TimePickerDialog(context: Context!, themeResId: Int, listener: TimePickerDialog.OnTimeSetListener!, hourOfDay: Int, minute: Int, is24HourView: Boolean)

Creates a new time picker dialog with the specified theme.

Public methods
open Unit
onClick(dialog: DialogInterface!, which: Int)

This method will be invoked when a button in the dialog is clicked.

open Unit
onRestoreInstanceState(savedInstanceState: Bundle)

Restore the state of the dialog from a previously saved bundle.

open Bundle

Saves the state of the dialog into a bundle.

open Unit
onTimeChanged(view: TimePicker!, hourOfDay: Int, minute: Int)

open Unit

Start the dialog and display it on screen.

open Unit
updateTime(hourOfDay: Int, minuteOfHour: Int)

Sets the current time.

Inherited functions

Public constructors

TimePickerDialog

Added in API level 1
TimePickerDialog(
    context: Context!,
    listener: TimePickerDialog.OnTimeSetListener!,
    hourOfDay: Int,
    minute: Int,
    is24HourView: Boolean)

Creates a new time picker dialog.

Parameters
context Context!: the parent context
listener TimePickerDialog.OnTimeSetListener!: the listener to call when the time is set
hourOfDay Int: the initial hour
minute Int: the initial minute
is24HourView Boolean: whether this is a 24 hour view or AM/PM

TimePickerDialog

Added in API level 1
TimePickerDialog(
    context: Context!,
    themeResId: Int,
    listener: TimePickerDialog.OnTimeSetListener!,
    hourOfDay: Int,
    minute: Int,
    is24HourView: Boolean)

Creates a new time picker dialog with the specified theme.

The theme is overlaid on top of the theme of the parent context. If themeResId is 0, the dialog will be inflated using the theme specified by the android:timePickerDialogTheme attribute on the parent context's theme.

Parameters
context Context!: the parent context
themeResId Int: the resource ID of the theme to apply to this dialog
listener TimePickerDialog.OnTimeSetListener!: the listener to call when the time is set
hourOfDay Int: the initial hour
minute Int: the initial minute
is24HourView Boolean: Whether this is a 24 hour view, or AM/PM.

Public methods

onClick

Added in API level 1
open fun onClick(
    dialog: DialogInterface!,
    which: Int
): Unit

This method will be invoked when a button in the dialog is clicked.

Parameters
dialog DialogInterface!: the dialog that received the click
which Int: the button that was clicked (ex. DialogInterface.BUTTON_POSITIVE) or the position of the item clicked

onRestoreInstanceState

Added in API level 1
open fun onRestoreInstanceState(savedInstanceState: Bundle): Unit

Restore the state of the dialog from a previously saved bundle. The default implementation restores the state of the dialog's view hierarchy that was saved in the default implementation of onSaveInstanceState(), so be sure to call through to super when overriding unless you want to do all restoring of state yourself.

Parameters
savedInstanceState Bundle: The state of the dialog previously saved by onSaveInstanceState().
This value cannot be null.

onSaveInstanceState

Added in API level 1
open fun onSaveInstanceState(): Bundle

Saves the state of the dialog into a bundle. The default implementation saves the state of its view hierarchy, so you'll likely want to call through to super if you override this to save additional state.

Return
Bundle A bundle with the state of the dialog.
This value cannot be null.

onTimeChanged

Added in API level 1
open fun onTimeChanged(
    view: TimePicker!,
    hourOfDay: Int,
    minute: Int
): Unit
Parameters
view TimePicker!: The view associated with this listener.
hourOfDay Int: The current hour.
minute Int: The current minute.

show

Added in API level 1
open fun show(): Unit

Start the dialog and display it on screen. The window is placed in the application layer and opaque. Note that you should not override this method to do initialization when the dialog is shown, instead implement that in onStart.

updateTime

Added in API level 1
open fun updateTime(
    hourOfDay: Int,
    minuteOfHour: Int
): Unit

Sets the current time.

Parameters
hourOfDay Int: The current hour within the day.
minuteOfHour Int: The current minute within the hour.