我已经实现了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);
}