自定义日期选择器.安卓 [英] Customize DatePicker. Android

查看:27
本文介绍了自定义日期选择器.安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法自定义 DatePicker?那是我的布局代码.

is there the way to customize a DatePicker? That is my Layout-Code.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <LinearLayout
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:gravity="center_horizontal" 
        android:orientation="vertical">
        <DatePicker 
            android:id="@+id/ad_date_picker"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:layout_margin="5dp"/>
        <TimePicker         
            android:id="@+id/ad_time_picker"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" 
            android:layout_margin="5dp"/>
    </LinearLayout>
</ScrollView>

在这种情况下,DatePicker 的日期格式是 MM-DD-YYYY,我希望将它放在 DD-MM-YYYY 中,如果也有可能,我希望使用月份的简称而不是数字.

In that case the date format of the DatePicker is MM-DD-YYYY and I'd like to have it in DD-MM-YYYY, and if it's also possible I'd like to have month's shortname instead of number.

我试图找到如何去做,但没有成功.

I've tried to find, how to do it, but without success.

谢谢,

推荐答案

您无法自定义默认方案.

You can't customize the default one.

来自用户界面页面:

Android 提供了一组完全实现的小部件,例如按钮、复选框和文本输入字段,因此您可以快速构建您的用户界面.Android 提供的一些小部件更为复杂,例如日期选择器、时钟和缩放控件.但您并不仅限于 Android 平台提供的各种小部件.如果您想做一些更自定义的事情并创建自己的可操作元素,您可以通过定义自己的 View 对象或扩展和组合现有小部件来实现.

Android provides a set of fully implemented widgets, like buttons, checkboxes, and text-entry fields, so you can quickly build your UI. Some widgets provided by Android are more complex, like a date picker, a clock, and zoom controls. But you're not limited to the kinds of widgets provided by the Android platform. If you'd like to do something more customized and create your own actionable elements, you can, by defining your own View object or by extending and combining existing widgets.

构建自定义组件中阅读更多内容.

这篇关于自定义日期选择器.安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆