public class DatePickerDialog
extends AlertDialog implements DialogInterface.OnClickListener, DatePicker.OnDateChangedListener
| java.lang.Object | |||
| android.app.Dialog | |||
| android.app.AlertDialog | |||
| android.app.DatePickerDialog | |||
一个包含 DatePicker简单对话框。
请参阅 Pickers指南。
Nested classes |
|
|---|---|
interface |
DatePickerDialog.OnDateSetListener 监听者用来指示用户完成选择日期。 |
Inherited constants |
|---|
android.app.AlertDialog
|
android.content.DialogInterface
|
Public constructors |
|
|---|---|
DatePickerDialog(Context context) 使用父上下文的默认日期选择器对话框主题为当前日期创建新的日期选择器对话框。 |
|
DatePickerDialog(Context context, int themeResId) 为当前日期创建一个新的日期选择器对话框。 |
|
DatePickerDialog(Context context, DatePickerDialog.OnDateSetListener listener, int year, int month, int dayOfMonth) 使用父上下文的默认日期选择器对话框主题为指定日期创建新的日期选择器对话框。 |
|
DatePickerDialog(Context context, int themeResId, DatePickerDialog.OnDateSetListener listener, int year, int monthOfYear, int dayOfMonth) 为指定的日期创建一个新的日期选择器对话框。 |
|
公共方法(Public methods) |
|
|---|---|
DatePicker |
getDatePicker() 返回此对话框中包含的 |
void |
onClick(DialogInterface dialog, int which) 当单击对话框中的按钮时,将调用此方法。 |
void |
onDateChanged(DatePicker view, int year, int month, int dayOfMonth) 根据日期变化调用。 |
void |
onRestoreInstanceState(Bundle savedInstanceState) 从先前保存的包中恢复对话框的状态。 |
Bundle |
onSaveInstanceState() 将对话框的状态保存到一个包中。 |
void |
setOnDateSetListener(DatePickerDialog.OnDateSetListener listener) 设置侦听器在用户设置日期时调用。 |
void |
updateDate(int year, int month, int dayOfMonth) 设置当前日期。 |
继承方法(Inherited methods) |
|
|---|---|
android.app.AlertDialog
|
|
android.app.Dialog
|
|
java.lang.Object
|
|
android.content.DialogInterface
|
|
android.view.Window.Callback
|
|
android.view.KeyEvent.Callback
|
|
android.view.View.OnCreateContextMenuListener
|
|
android.content.DialogInterface.OnClickListener
|
|
android.widget.DatePicker.OnDateChangedListener
|
|
DatePickerDialog (Context context)
使用父上下文的默认日期选择器对话框主题为当前日期创建新的日期选择器对话框。
| 参数(Parameters) | |
|---|---|
context |
Context: the parent context |
DatePickerDialog (Context context, int themeResId)
为当前日期创建一个新的日期选择器对话框。
| 参数(Parameters) | |
|---|---|
context |
Context: the parent context |
themeResId |
int: the resource ID of the theme against which to inflate this dialog, or 0 to use the parent context's default alert dialog theme |
DatePickerDialog (Context context, DatePickerDialog.OnDateSetListener listener, int year, int month, int dayOfMonth)
使用父上下文的默认日期选择器对话框主题为指定日期创建新的日期选择器对话框。
| 参数(Parameters) | |
|---|---|
context |
Context: the parent context |
listener |
DatePickerDialog.OnDateSetListener: the listener to call when the user sets the date |
year |
int: the initially selected year |
month |
int: the initially selected month (0-11 for compatibility with MONTH) |
dayOfMonth |
int: the initially selected day of month (1-31, depending on month) |
DatePickerDialog (Context context, int themeResId, DatePickerDialog.OnDateSetListener listener, int year, int monthOfYear, int dayOfMonth)
为指定的日期创建一个新的日期选择器对话框。
| 参数(Parameters) | |
|---|---|
context |
Context: the parent context |
themeResId |
int: the resource ID of the theme against which to inflate this dialog, or 0 to use the parent context's default alert dialog theme |
listener |
DatePickerDialog.OnDateSetListener: the listener to call when the user sets the date |
year |
int: the initially selected year |
monthOfYear |
int: the initially selected month of the year (0-11 for compatibility with MONTH) |
dayOfMonth |
int: the initially selected day of month (1-31, depending on month) |
DatePicker getDatePicker ()
返回此对话框中包含的 DatePicker 。
| 返回(Returns) | |
|---|---|
DatePicker |
the date picker |
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. |
void onDateChanged (DatePicker view, int year, int month, int dayOfMonth)
根据日期变化调用。
| 参数(Parameters) | |
|---|---|
view |
DatePicker: The view associated with this listener. |
year |
int: The year that was set. |
month |
int: The month that was set (0-11) for compatibility with Calendar. |
dayOfMonth |
int: The day of the month that was set. |
void onRestoreInstanceState (Bundle savedInstanceState)
从先前保存的包中恢复对话框的状态。 默认实现恢复默认实现onSaveInstanceState()保存的对话框视图层次结构的onSaveInstanceState() ,因此,除非您想自己完成所有状态的恢复,否则一定要在覆盖时调用超级对象。
| 参数(Parameters) | |
|---|---|
savedInstanceState |
Bundle: The state of the dialog previously saved by onSaveInstanceState(). |
Bundle onSaveInstanceState ()
将对话框的状态保存到一个包中。 默认的实现保存了它的视图层次结构的状态,所以如果你重写这个来保存更多的状态,你可能想要调用super。
| 返回(Returns) | |
|---|---|
Bundle |
A bundle with the state of the dialog. |
void setOnDateSetListener (DatePickerDialog.OnDateSetListener listener)
设置侦听器在用户设置日期时调用。
| 参数(Parameters) | |
|---|---|
listener |
DatePickerDialog.OnDateSetListener: the listener to call when the user sets the date |
void updateDate (int year,
int month,
int dayOfMonth)
设置当前日期。
| 参数(Parameters) | |
|---|---|
year |
int: the year |
month |
int: the month (0-11 for compatibility with MONTH) |
dayOfMonth |
int: the day of month (1-31, depending on month) |