"ui";
ui.layout(
<scroll>
<vertical >
<text id="timepickerText" text="时钟样式时间选择: " textColor="black" textSize="16sp" marginTop="16" />
<timepicker id="timepicker" />
<text id="timePickerModeText" text="滑动时间选择: " textColor="black" textSize="16sp" marginTop="16" />
<timepicker id="timePickerMode" timePickerMode="spinner" />
</vertical>
</scroll>
)
//时钟样式时间选择
ui.timepicker.setOnTimeChangedListener({
onTimeChanged: function (v, h, m) {
//h 获取的值 为24小时格式
let time = h + ":" + m ;
ui.timepickerText.setText("时钟样式时间选择: " + time);
}
});
//滑动时间选择
ui.timePickerMode.setIs24HourView(true);//设置当前时间控件为24小时制
ui.timePickerMode.setOnTimeChangedListener({
onTimeChanged: function (v, h, m) {
//h 获取的值 为24小时格式
let time = h + ":" + m ;
ui.timePickerModeText.setText("滑动时间选择: " + time);
}
});
autojs时间选择器
于 2021-07-28 11:53:15 首次发布