android datepickerdialog 時間上下限問題

在做日期選擇時,遇到了當日期年份在1900年之前或者在2038年之後出現異常顯示的問題(上下限依不同手機可能不同),google了一下,發現只能是通過設置activity的theme來更改
例如

<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中添加:

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

 

 

參考鏈接

http://stackoverflow.com/questions/8620781/datepickerdialog-incorrectly-enforcing-a-minimum-date-of-jan-1-1970

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章