UI
TimePicker
<TimePicker>
is a UI component that lets users select time.
See also: DatePicker.
Creating a simple TimePicker
To listen to time change event, handle the timeChange
event in the loaded
event handler of the <TimePicker>
<TimePicker
hour="10"
minute="25"
loaded="onPickerLoaded"
/>
import { TimePicker } from '@nativescript/core'
export function onPickerLoaded(args) {
const timePicker = args.object as TimePicker
// Configurable properties of TimePicker
timePicker.hour = 10
timePicker.minute = 25
timePicker.minuteInterval = 5
timePicker.minHour = 7
timePicker.maxHour = 11
timePicker.minMinute = 10
timePicker.maxMinute = 45
timePicker.on('timeChange', (data: PropertyChangeData) => {
// data is of type PropertyChangeData
console.log('Picked TIME: ', data.value)
console.log('Previous TIME: ', data.oldValue)
})
}
Props
hour
<TimePicker hour="10"/>
timePicker.hour = 10
Gets or sets the selected hour.
minute
<TimePicker minute="10"/>
timePicker.minute = 25
Gets or sets the selected minute.
time
time: Date = timePicker.time
Gets or sets the selected time.
minHour
<TimePicker minHour="7"/>
timePicker.minHour = 7
Gets or sets the minimum selectable hour.
maxHour
<TimePicker maxHour="7"/>
timePicker.maxHour = 11
Gets or sets the maximum selectable hour.
minMinute
<TimePicker minMinute="10"/>
timePicker.minMinute = 10
Gets or sets the minimum selectable minute.
maxMinute
<TimePicker maxMinute="45"/>
timePicker.maxMinute = 45
Gets or sets the maximum selectable minute.
minuteInterval
<TimePicker minuteInterval="45"/>
timePicker.minuteInterval = 45
Gets or sets the selectable minute interval. Default
:1
.
Inherited Props
For additional inherited properties not shown, refer to the API Reference |
Events
timeChange
timePicker.on('timeChange', (data: PropertyChangeData) => {
console.log('Picked TIME: ', data.value)
console.log('Previous TIME: ', data.oldValue)
})
Emitted when the selected time changes. See the PropertyChangeData interface for available event data properties.
Native component
Android | iOS |
---|---|
android.widget.TimePicker | UIDatePicker |