Dialog DatePicker android 2.x start year

1k Views Asked by At

I have datepickerdialog like this:

birthDateDialog = new DatePickerDialog(AddGrave.this, R.style.datePickerStyle, birthDateDialogListener, 
birthCalendar.get(Calendar.YEAR), 
birthCalendar.get(Calendar.MONTH), 
birthCalendar.get(Calendar.DAY_OF_MONTH));
birthDateDialog.show();

and style:

<style name="datePickerStyle" parent="AppTheme">
    <item name="android:endYear">2200</item>
    <item name="android:startYear">1000</item>
</style>

It works properly on android 4.x, but on android 2.2/2.3 range of the year is still 1900-2100. How can i change that range?

1

There are 1 best solutions below

5
On

Perhaps it is because setMaxDate and setMinDate were not introduced until API 11. These xml attributes might rely on these methods. I'm speculating here, since the documentation does not list a min API level for these xml attributes. Here is a workaround to setMaxDate programmatically.