android - 如何在 Android 中创建插槽选择器(分钟/小时)?

标签 android picker

我想按照下图创建时间段选择器对话框:

enter image description here

有谁知道我怎样才能做到这一点?我们有日期和时间选择器,但我们在 Android 中没有这种类型的 native 槽选择器。谢谢

最佳答案

您可以使用控件NumberPicker

例如:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="match_parent">

<NumberPicker
    android:id="@+id/number_picker_hour"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:configChanges="keyboard|keyboardHidden" />

<NumberPicker
    android:id="@+id/number_picker_min"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:configChanges="keyboard|keyboardHidden" />
</LinearLayout>

关于android - 如何在 Android 中创建插槽选择器(分钟/小时)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45706819/

相关文章:

Android - 如何拥有第二套资源?

date - 如何在 flutter 中创建计时器选择器?

android - 在 xamarin.forms 中自定义下拉列表(选择器)

callback - 向 SwiftUI Picker 添加回调

android - 导致致命信号 11 的 Google map fragment

android - 使用 Intent 共享文本 + 链接

android - 如何下载带有所有依赖项的 Artifact ?

c# - 如何在 Unity 中从 sdcard 写入/读取 txt 文件?

android - 在 Android 的 TimePicker 中显示当前时间

wordpress - 自定义 Wordpress 颜色选择器