반응형
Public Constructors
public DatePickerDialog (Context context, DatePickerDialog.OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth)
Since: API Level 1
Parameters
| context | The context the dialog is to run in. |
|---|---|
| callBack | How the parent is notified that the date is set. |
| year | The initial year of the dialog. |
| monthOfYear | The initial month of the dialog. |
| dayOfMonth | The initial day of the dialog. |
public DatePickerDialog (Context context, int theme, DatePickerDialog.OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth)
Since: API Level 1
Parameters
| context | The context the dialog is to run in. |
|---|---|
| theme | the theme to apply to this dialog |
| callBack | How the parent is notified that the date is set. |
| year | The initial year of the dialog. |
| monthOfYear | The initial month of the dialog. |
| dayOfMonth | The initial day of the dialog. |
Public Methods
public DatePicker getDatePicker ()
Since: API Level 11
Gets the DatePicker contained in this dialog.
Returns
- The calendar view.
public void onClick (DialogInterface dialog, int which)
Since: API Level 1
This method will be invoked when a button in the dialog is clicked.
Parameters
| dialog | The dialog that received the click. |
|---|---|
| which | The button that was clicked (e.g. BUTTON1) or the position of the item clicked. |
public void onDateChanged (DatePicker view, int year, int month, int day)
Since: API Level 1
Called upon a date change.
Parameters
| view | The view associated with this listener. |
|---|---|
| year | The year that was set. |
| month | The month that was set (0-11) for compatibility with Calendar. |
| day | The day of the month that was set. |
public void onRestoreInstanceState (Bundle savedInstanceState)
Since: API Level 1
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 | The state of the dialog previously saved by onSaveInstanceState(). |
|---|
public Bundle onSaveInstanceState ()
Since: API Level 1
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.
Returns
- A bundle with the state of the dialog.
public void updateDate (int year, int monthOfYear, int dayOfMonth)
Since: API Level 1
Sets the current date.
Parameters
| year | The date year. |
|---|---|
| monthOfYear | The date month. |
| dayOfMonth | The date day of month. |
위 개발문서 참고해서 DataPicker Dialog 사용을 해주시길 바랍니다.
DataPicker은 날짜를 선택받는 안드로이드에서 제공해주는 API 입니다.
아마 많은 어플에서 보셨을텐데요. 간단하게 예를 사용하면,
Calendar c = Calendar.getInstance();
int cyear = Integer.parseInt(selected_year);
int cmonth = Integer.parseInt(selected_month)-1;
int cday = Integer.parseInt(selected_day);
// Calendar 을 통해 현재 날짜를 받아옴,
// Calendar 을 통해 현재 날짜를 받아옴,
DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener()
{
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth)
{///실제적으로 선택된 날짜를 Set하는 등의 명령
}
};
로 사용이 가능합니다.
(기본적인 예제이니 응용해서 사용하셔요)
반응형
'옛글 > 코드창고' 카테고리의 다른 글
| [Android] String Array Sort (Str[]) (0) | 2012.08.27 |
|---|---|
| [Android] UTC 16진수 Date Format으로 변환하기 (0) | 2012.03.22 |
| 안드로이드 ArrayList Sort하는 Collection (0) | 2012.01.18 |
| 안드로이드 WebView 로딩 중 게이지 막대표시하기 (0) | 2012.01.11 |
| 안드로이드 WebView 로딩 게이지 구현하기 (0) | 2012.01.11 |