TimerPicker(Android 7.0)

<TimePicker
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

</TimePicker>

Android Studio菜鸟开发————TimePicker DataPicker 日期与时间

在Java文件中可以使用findViewById来找到该控件

使用setIs24HourView(true)来设置为24时制

使用OnTimeChangedListener来监听

也可以直接通过getCurrentHour(),getCurrentMinute()来分别获取TimePicker的小时和分钟

----------------------

DataPicker

<DatePicker
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
</DatePicker>

Android Studio菜鸟开发————TimePicker DataPicker 日期与时间

在Java文件中可以使用findViewById来找到该控件

没有监听器

可以使用updateDate()来设置datePicker显示的默认日期,不设置显示当前日期

可以通过getYear(),getMounth(),getDayOfMounth()来分别获取年月日





相关文章:

  • 2022-12-23
  • 2021-12-07
  • 2021-12-06
  • 2021-11-27
  • 2021-07-03
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2022-12-23
  • 2021-08-19
  • 2021-07-12
  • 2022-12-23
  • 2021-10-06
  • 2022-01-20
  • 2022-12-23
相关资源
相似解决方案