java.lang.Object | ||
↳ | com.neomades.ui.View | |
↳ | com.neomades.ui.TimePicker |
This view lets the user pick a Time.
Only hours and minutes are available.
Default properties
By default, the following properties are applied to a new TimePicker:
MATCH_CONTENT.
MATCH_CONTENT.
HCENTER|VCENTER.
TimeChangedListener timeListener = new TimeChangedListener() { public void onTimeChanged(View source, int hours, int minutes, int seconds) { // do some stuff } }; TimePicker myTimePicker = new TimePicker(); myTimePicker.setDateChangedListener(dateListener);
The TimePicker
has two modes :
MODE_INLINE
, MODE_DIALOG_PICKER
. The MODE_INLINE
enables wrapping TimePicker control inside a Layout
. The
MODE_DIALOG_PICKER
mode shows a button with the selected time, when
the end-user click him, a dialog is displayed :
TimePickerDialog
.
By default, the following properties are applied to a new TimePicker:
MATCH_CONTENT.
MATCH_CONTENT.
HCENTER|VCENTER.
MODE_DIALOG_PICKER
XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Attribute Name | Related Method | Description | |||||||||
contentAlignment | setContentAlignment(int) | A combination of alignment values (eg: TOP|LEFT) | |||||||||
font | setFont(Font) | Font resource id: Res.font.FONT_XXXX | |||||||||
hours | setHours(int) | If the view could be clicked | |||||||||
minutes | setMinutes(int) | ||||||||||
textColor | setTextColor(Color) | #AARRGGBB or a color | |||||||||
textSize | setTextSize(int) | a size in dp |
[Expand]
Inherited XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | MODE_DIALOG_PICKER | A button is displayed with the value of Time. | |||||||||
int | MODE_INLINE | The TimePicker inputs will be displayed directly in the layout. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
TimePicker()
Constructs a new time picker with the time set to the current time, and 24
hours mode activated by default.
| |||||||||||
TimePicker(int mode)
Constructs a new time picker with the time set to the current time, and 24
hours mode activated by default.
| |||||||||||
TimePicker(int hours, int minutes, boolean mode)
Constructs a new time picker with the time set to the given parameters.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int |
getHours()
Returns the hours of this time picker (always between 0 and 23)
| ||||||||||
int |
getMinutes()
Returns the minutes of this time picker (always between 0 and 59)
| ||||||||||
boolean |
is24HoursMode()
Returns if the time picker is configured in the 24 hours mode.
| ||||||||||
static void |
openChooser(View origin, Calendar selectedTime, boolean is24hoursMode, TimeChangedListener listener)
Opens a dialog to choose a Time.
| ||||||||||
void |
set24HoursMode(boolean mode)
Sets the time picker mode to 24 hours.
| ||||||||||
void |
setContentAlignment(int alignment)
Sets the alignment of the text or icon in the button.
| ||||||||||
void |
setFont(Font font)
Sets the timepicker's button text font.
| ||||||||||
void |
setHours(int hours)
Sets the hours of this time picker (always between 0 and 23)
| ||||||||||
void |
setMinutes(int minutes)
Sets the minutes of this time picker (always between 0 and 59)
| ||||||||||
void |
setTextColor(Color textColor)
Sets the TimePicker text color.
| ||||||||||
void |
setTextSize(int sizeInDp)
Sets the text size to a given value (in dp).
| ||||||||||
void |
setTimeChangedListener(TimeChangedListener listener)
Sets the listener for this TimePicker, that will be notified if the time
changes.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
A combination of alignment values (eg: TOP|LEFT)
A button is displayed with the value of Time. When the user clicks on the button, a Dialog is displayed in order to pick a Time.
Default mode for all platforms.
The TimePicker inputs will be displayed directly in the layout.
In this mode, text customization methods and background customization methods do nothing (text color, text font, text size, text alignment, background color...).
Constructs a new time picker with the time set to the current time, and 24 hours mode activated by default.
The mode used here is MODE_DIALOG_PICKER.
Constructs a new time picker with the time set to the current time, and 24 hours mode activated by default.
This constructor enables to choose between MODE_DIALOG_PICKER and MODE_INLINE. The default mode is MODE_DIALOG_PICKER.
Constructs a new time picker with the time set to the given parameters.
hours | the hour to set to this time picker. This value must be between 0 and 23. |
---|---|
minutes | the minute to set to this time picker. This value must be between 0 and 59. |
mode | the 24 hours mode to set (true to enable the 24Hours mode, false to enable the AM/PM mode) |
Returns the hours of this time picker (always between 0 and 23)
Returns the minutes of this time picker (always between 0 and 59)
Returns if the time picker is configured in the 24 hours mode.
Opens a dialog to choose a Time.
origin | the view from here the dialog should be opened in iOS. |
---|---|
selectedTime | the selected time when the chooser will be shown at the user |
is24hoursMode | true for 24H mode, false for AM/PM |
listener | the callback used to get the selected date or null |
NullPointerException | for iOS if the origin parameter is
null .
|
---|
Sets the time picker mode to 24 hours. The time will be displayed differently, according to the mode.
mode | true to set the mode to 24 hours, else false (mode AM/PM) |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
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 timepicker's text |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the timepicker'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 hours of this time picker (always between 0 and 23)
hours | the hours to set (always between 0 and 23) |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the minutes of this time picker (always between 0 and 59)
minutes | the minutes to set (always between 0 and 59) |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the TimePicker 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 listener for this TimePicker, that will be notified if the time changes.
listener | the listener |
---|