How can I set custom months\' names in Android DatePicker? For example: new String[]{\"January\", \"February\", ... }.
You could create a custom DatePicker
that extends the system class DatePicker like this:
class MyCustomDatePicker extends DatePicker {
public MyCustomDatePicker(Context context, AttributeSet attrs) {
super(context, attrs);
Field[] fields = DatePicker.class.getDeclaredFields();
try {
String[] s = new String[] {"January","February","March","April","May","June","July","August","September","October","November","December"};
for (Field field : fields) {
field.setAccessible(true);
if (TextUtils.equals(field.getName(), "mMonthSpinner")) {
NumberPicker monthPicker = (NumberPicker) field.get(this);
monthPicker.setMinValue(0);
monthPicker.setMaxValue(11);
monthPicker.setDisplayedValues(s);
}
if (TextUtils.equals(field.getName(), "mShortMonths")) {
field.set(this, s);
}
}
}
catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
And then you need to declare the DatePicker as your custom datePicker in the xml layout like this for example: