DatePickerDialog错误地执行1970年1月1日的最低日期 [英] DatePickerDialog incorrectly enforcing a minimum date of Jan 1, 1970

查看:1027
本文介绍了DatePickerDialog错误地执行1970年1月1日的最低日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个成员报告说,他无法1970年1月1日我们的DatePickerDialog之前设置一个日期。此问题不瑞普我们。

We have a member reporting that he is unable to set a date before Jan 1, 1970 on our DatePickerDialog. This issue does not repro for us.

我已经知道,DatePickerDialog不暴露底层的DatePicker的setMinDate / setMaxDate功能,所以它似乎是某种形式的手机制造商的具体修改影响为MinDate /的maxDate。

I am already aware that the DatePickerDialog does not expose the setMinDate/setMaxDate functions of the underlying DatePicker, so it would seem that some kind of handset maker-specific modification is affecting the minDate/maxDate.

该用户报告,他是​​在Verizon运行的Droid X2跑2.2升级Froyo。虽然我们认为他是在自己的设备模型的他的描述正确的,很多用户感到困惑的操作系统版本,因此他可能正在运行2.3。

This user reports he is running a Droid x2 on Verizon running 2.2 Froyo. While we believe he is correct in his description of his device model, many users are confused about the OS version, so he may be running 2.3.

我试图通过加入这一主题,以我的活动来解决这个问题:

I attempted to solve this problem by adding this theme to my Activity:

<style name="profile_editor_theme">     
    <item name="android:endYear">2025</item>
    <item name="android:startYear">1910</item>
</style>

虽然这个主题在我的活动有约束DatePickerDialog在我的测试设备(银河标签和原始摩托罗拉Droid)的预期效果,这显然有对用户无影响。

While this theme on my activity had the intended effect of constraining the DatePickerDialog on my test devices (a Galaxy tab and an original Motorola Droid), it apparently had no effect for the user.

这个问题repros,但正常工作为我们在我们自己的设备。

This issue repros for our user 100% of the time, but works correctly for us on our own devices.

任何人能解释什么可能导致这一点,我们如何解决这个问题?

Can anyone explain what might be causing this and how we could fix it?

我有<一个href="http://$c$c.google.com/p/android/issues/detail?id=23481&thanks=23481&ts=1324675034">filed对谷歌这个错误的在这个问题上。

谢谢!

推荐答案

开始Android设备的日期从1月1日,1970年开始也许这可能是你的情况。 Android的计算时间为毫秒数自1970年1月1日通过了。

Starting date of Android devices starts from Jan 1, 1970. Maybe this can be your case. Android calculates time as a number of milliseconds passed since Jan 1, 1970.

我已经找到了一种黑客对你的情况。 在这里,我动态创建日期选择器:

I've found a kind of hack for your case. Here I create dynamically datePicker:

     DatePicker dp = new DatePicker(this);
     dp.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
     v.addView(dp);

在清单文件我宣布一个自定义的主题我的应用程序 - 我想同样主题的应用程序。顺便说一句,你能为活动做同样的。

In the manifest file I declare a custom theme for my application - I want the same theme for the application. By the way you can do the same for activity.

 <application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" 
    android:theme="@style/CustomTheme">
    <activity
        android:name=".HelloDatePickerActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

在一个styles.xml我这样做:

In a styles.xml I do this:

<style name="CustomTheme" parent="android:Theme.Light">
    <item name="android:startYear">1890</item>
</style>

在我的情况下,默认的开始日期为1900年。因此,对于我这种方法效果。

The default start date in my case is 1900. Thus, for me this approach works.

希望这会帮助你!

这篇关于DatePickerDialog错误地执行1970年1月1日的最低日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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