如何将文本插入datepicker中?

发布于 2025-02-12 07:43:11 字数 1451 浏览 1 评论 0原文

我需要将文本插入本机Android datePicker。我该怎么做?

这是我的布局代码:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="700px"
    android:layout_height="300px"
    android:background="@drawable/time_format_24"
    android:gravity="center"
    android:orientation="horizontal">

    <TableRow>
        <!-- define a TimePicker module -->
        <DatePicker
            android:id="@+id/datePicker"
            android:layout_width="420px"
            android:layout_height="match_parent"
            android:layout_gravity="center_horizontal"
            android:calendarViewShown="false"
            android:datePickerMode="spinner"
            android:endYear="2200"
            android:spinnersShown="true"
            android:startYear="2010"
            android:theme="@style/Theme.picker" />
        <TimePicker
            android:id="@+id/timePicker"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="center_horizontal"
            android:theme="@style/Theme.picker"
            android:timePickerMode="spinner" />
    </TableRow>
</TableLayout>

要实现的最终效果是:

”在此处输入图像描述”

I need to insert text into the native Android DatePicker. How do I do this?

Here is my layout code:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="700px"
    android:layout_height="300px"
    android:background="@drawable/time_format_24"
    android:gravity="center"
    android:orientation="horizontal">

    <TableRow>
        <!-- define a TimePicker module -->
        <DatePicker
            android:id="@+id/datePicker"
            android:layout_width="420px"
            android:layout_height="match_parent"
            android:layout_gravity="center_horizontal"
            android:calendarViewShown="false"
            android:datePickerMode="spinner"
            android:endYear="2200"
            android:spinnersShown="true"
            android:startYear="2010"
            android:theme="@style/Theme.picker" />
        <TimePicker
            android:id="@+id/timePicker"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="center_horizontal"
            android:theme="@style/Theme.picker"
            android:timePickerMode="spinner" />
    </TableRow>
</TableLayout>

The final effect to be achieved is this:

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

请你别敷衍 2025-02-19 07:43:11

使用自定义日期Piker库使用此库进行此操作,您可以在一个日期进行任何类型的自定义布局。

库链接: https://github.com/kizitonwose/calendonwose/calendarview

注意: datepicker中的单日期布局

Use the custom date piker library to do this using this library you can do any type of custom layout for a single date.

Library link: https://github.com/kizitonwose/CalendarView

Note: you can not change the custom single date layout in DatePicker

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文