Most visited

Recently visited

Added in API level 1

TimePickerDialog

public class TimePickerDialog
extends AlertDialog implements DialogInterface.OnClickListener, TimePicker.OnTimeChangedListener

java.lang.Object
   ↳ android.app.Dialog
     ↳ android.app.AlertDialog
       ↳ android.app.TimePickerDialog


使用 TimePicker提示用户一天中的时间的 TimePicker

请参阅 Pickers指南。

Summary

Nested classes

interface TimePickerDialog.OnTimeSetListener

用于指示用户的回调接口已完成填充时间(例如,

Inherited constants

From class android.app.AlertDialog
From interface android.content.DialogInterface

Public constructors

TimePickerDialog(Context context, TimePickerDialog.OnTimeSetListener listener, int hourOfDay, int minute, boolean is24HourView)

创建一个新的时间选择器对话框。

TimePickerDialog(Context context, int themeResId, TimePickerDialog.OnTimeSetListener listener, int hourOfDay, int minute, boolean is24HourView)

用指定的主题创建一个新的时间选择器对话框。

Public methods

void onClick(DialogInterface dialog, int which)

当单击对话框中的按钮时,将调用此方法。

void onRestoreInstanceState(Bundle savedInstanceState)

从先前保存的包中恢复对话框的状态。

Bundle onSaveInstanceState()

将对话框的状态保存到一个包中。

void onTimeChanged(TimePicker view, int hourOfDay, int minute)
void updateTime(int hourOfDay, int minuteOfHour)

设置当前时间。

Inherited methods

From class android.app.AlertDialog
From class android.app.Dialog
From class java.lang.Object
From interface android.content.DialogInterface
From interface android.view.Window.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.View.OnCreateContextMenuListener
From interface android.content.DialogInterface.OnClickListener
From interface android.widget.TimePicker.OnTimeChangedListener

Public constructors

TimePickerDialog

Added in API level 1
TimePickerDialog (Context context, 
                TimePickerDialog.OnTimeSetListener listener, 
                int hourOfDay, 
                int minute, 
                boolean is24HourView)

创建一个新的时间选择器对话框。

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, 
                int themeResId, 
                TimePickerDialog.OnTimeSetListener listener, 
                int hourOfDay, 
                int minute, 
                boolean is24HourView)

用指定的主题创建一个新的时间选择器对话框。

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
void onClick (DialogInterface dialog, 
                int which)

当单击对话框中的按钮时,将调用此方法。

Parameters
dialog DialogInterface: The dialog that received the click.
which int: The button that was clicked (e.g. BUTTON1) or the position of the item clicked.

onRestoreInstanceState

Added in API level 1
void onRestoreInstanceState (Bundle savedInstanceState)

从先前保存的包中恢复对话框的状态。 默认实现恢复默认实现onSaveInstanceState()保存的对话框视图层次结构的onSaveInstanceState() ,因此,除非您想自己完成所有恢复状态,否则请务必在覆盖时调用超级对象。

Parameters
savedInstanceState Bundle: The state of the dialog previously saved by onSaveInstanceState().

onSaveInstanceState

Added in API level 1
Bundle onSaveInstanceState ()

将对话框的状态保存到一个包中。 默认的实现保存了它的视图层次结构的状态,所以如果你重写这个来保存更多的状态,你可能想要调用super。

Returns
Bundle A bundle with the state of the dialog.

onTimeChanged

Added in API level 1
void onTimeChanged (TimePicker view, 
                int hourOfDay, 
                int minute)

Parameters
view TimePicker
hourOfDay int
minute int

updateTime

Added in API level 1
void updateTime (int hourOfDay, 
                int minuteOfHour)

设置当前时间。

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

Hooray!