java.lang.Object | ||
↳ | com.neomades.ui.View | |
↳ | com.neomades.ui.DatePicker |
This control lets the user pick a Date.
Day, month and year are available.
DateChangedListener dateListener = new DateChangedListener() { public void onDateChanged(View source, int day, int month, int year) { // do some stuff } }; DatePicker myDatePicker = new DatePicker(); myDatePicker.setDateChangedListener(dateListener);
By default, the following properties are applied to a new DatePicker:
MATCH_CONTENT.
MATCH_CONTENT.
HCENTER|VCENTER.
MODE_DIALOG_PICKER
In Android
, the DatePicker
has two modes :
MODE_INLINE
, MODE_DIALOG_PICKER
. The MODE_INLINE
enables wrapping DatePicker control inside a Layout
. The
MODE_DIALOG_PICKER
mode shows a button with the selected date, when
the end-user click him, a dialog is displayed :
DatePickerDialog
.
XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Attribute Name | Related Method | Description | |||||||||
contentAlignment | setContentAlignment(int) | A combination of alignment values (eg: TOP|LEFT) | |||||||||
day | setDay(int) | Between 1 and 31 | |||||||||
font | setFont(Font) | Font resource id: Res.font.FONT_XXXX | |||||||||
month | setMonth(int) | 1: JANUARY, 12: DECEMBER | |||||||||
textColor | setTextColor(Color) | #AARRGGBB or a color | |||||||||
textSize | setTextSize(int) | a size in dp | |||||||||
year | setYear(int) |
[Expand]
Inherited XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | MODE_DIALOG_PICKER | A button is displayed with the value of Date. | |||||||||
int | MODE_INLINE | Three editors are displayed into the layout in order to input values of Date. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
DatePicker(int mode)
Constructs a new date picker with the date set to today's day, month and
year.
| |||||||||||
DatePicker()
Constructs a new date picker with the date set to today's day, month and
year.
| |||||||||||
DatePicker(int day, int month, int year)
Constructs a new DatePicker with the date set to the given parameters.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Calendar |
getCalendar()
Gets the calendar object with the selected date in this picker
| ||||||||||
Date |
getDate()
Gets the date object with the selected date in this picker
| ||||||||||
int |
getDay()
Returns the day of this DatePicker (always between 1 and 31)
| ||||||||||
int |
getMonth()
Returns the month of this DatePicker (always between 1 and 12)
| ||||||||||
int |
getYear()
Returns the year of this DatePicker (always between -Infinity and +Infinity)
| ||||||||||
static void |
openChooser(View origin, Calendar selectedDate, DateChangedListener listener)
Shows a
dialog chooser to the user in order to select a
date . | ||||||||||
void |
setContentAlignment(int alignment)
Sets the alignment of the text or icon in the button.
| ||||||||||
void | setDate(Calendar date) | ||||||||||
void |
setDate(Date date)
Sets the date of the DatePicker to the given date Only the day, month and
year components will be taken into acount
| ||||||||||
void |
setDateChangedListener(DateChangedListener listener)
Sets the listener for this DatePicker, that will be notified if the date
changes.
| ||||||||||
void |
setDay(int day)
Sets the day number to set (always between 1 and 31)
| ||||||||||
void |
setFont(Font font)
Sets the datepicker's button text font.
| ||||||||||
void |
setMonth(int month)
Sets the months of this date picker (always between 1 and 12)
| ||||||||||
void |
setTextColor(Color textColor)
Sets the DatePicker text color.
| ||||||||||
void |
setTextSize(int sizeInDp)
Sets the text size to a given value (in dp).
| ||||||||||
void |
setToday()
Sets the date of the DatePicker to today's date
| ||||||||||
void |
setYear(int year)
Sets the year of this DatePicker (must be positive)
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
A combination of alignment values (eg: TOP|LEFT)
A button is displayed with the value of Date. When the user clicks on the button, a Dialog is displayed in order to pick a Date.
Default mode for all platforms.
Three editors are displayed into the layout in order to input values of Date. Only available for Android.
In this mode, text customization methods do nothing (text color, text font, text size and text alignment).
Constructs a new date picker with the date set to today's day, month and year.
Constructs a new date picker with the date set to today's day, month and year.
The mode used here is MODE_DIALOG_PICKER.
Constructs a new DatePicker with the date set to the given parameters.
day | the day to set to this date picker. This value must be between 1 and 31. |
---|---|
month | the month to set to this date picker. This value must be between 1 and 12. |
year | the year number |
Gets the calendar object with the selected date in this picker
Gets the date object with the selected date in this picker
Returns the day of this DatePicker (always between 1 and 31)
Returns the month of this DatePicker (always between 1 and 12)
Returns the year of this DatePicker (always between -Infinity and +Infinity)
Shows a dialog chooser
to the user in order to select a
date
.
origin | the view from here the dialog should be opened in iOS. |
---|---|
selectedDate | the selected date when the chooser will be shown at the user |
listener | the callback used to get the selected date or null |
NullPointerException | for iOS if the origin parameter is
null . |
---|
Sets the alignment of the text or icon in the button. The parameter is a
combination of values from Alignment
Only available in MODE_DIALOG_PICKER
.
alignment | The new alignment of the button's text |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the date of the DatePicker to the given date Only the day, month and year components will be taken into acount
date | the date to set |
---|
Sets the listener for this DatePicker, that will be notified if the date changes.
listener | the listener |
---|
Sets the day number to set (always between 1 and 31)
CrossThreadException | if the method is called from outside the UI-Thread |
---|---|
IllegalArgumentException | if the day value is not between 1 and 31 |
Sets the datepicker's button text font.
font | new font for the text |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|---|
NullPointerException | if the font parameter is null |
Sets the months of this date picker (always between 1 and 12)
month | the hours to set (always between 1 and 12) |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|---|
IllegalArgumentException | if the month value is not between 1 and 12 |
Sets the DatePicker text color.
textColor | new color for the text |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|---|
NullPointerException | if the parameter is null |
Sets the text size to a given value (in dp).
sizeInDp | size to set to the text |
---|
Sets the date of the DatePicker to today's date
Sets the year of this DatePicker (must be positive)
year | the years to set |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|---|
IllegalArgumentException | if the year value is negative |