timepicker不显示小时棒棒糖版本5.1.0

时间:2018-05-15 13:01:46

标签: java android timepicker

enter image description here

我已经实现了android默认时间选择器,但运行时没有显示小时数,请查看下面的屏幕截图。

XML文件

 <TimePicker
    android:id="@+id/timePicker"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    android:timePickerMode="clock"
    android:headerBackground="@color/colorPrimary"
   />

Java文件

TimePicker timePicker = findViewById(R.id.timePicker)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
   timePicker.setHour(this.hour);
   timePicker.setMinute(this.min);
}else{
   timePicker.setCurrentHour(this.hour);
   timePicker.setCurrentMinute(this.min);
}

0 个答案:

没有答案