Reputation: 1364
I am using MaterialDatePicker in my android app project. The app also supports multiple local languages. Now the issue is that when i select app langauge other then English the calendar language also changes to the selected one. How can i fix the calendar language to English only. Below is the code for the MaterialDatePicker:
val datePicker = MaterialDatePicker.Builder.datePicker()
.setTheme(R.style.ThemeOverlay_App_MaterialCalendar)
.setTitleText("Select Date")
.setCalendarConstraints(
CalendarConstraints.Builder()
.setValidator(
DateValidatorPointBackward.now()
)
.build()
)
.build()
I have read the official document and also searched through stackoverflow, but haven't found anything related to this.
Upvotes: 1
Views: 192
Reputation: 1
I have the same problem but in a différent way i want the opposite of what u suggest my app support only english and i want to change the language displayed in the date picker to another language (only one in the date picker) so the same solution here will be great ***If u are using a button or edit text to show the date picker i suggest to use on click listener -Create a value currentLocale to get the default locale of user u will need it to restore the locale -change the locale before the date picker build methode to english or what u want to bé displayed in the date picker Than return the locale to the currentlocale in ondismisslistener of the datepicker I think this will help because the locale will be changed only when opening the date picker and returned when it will dissmiss.. Adjust the locale first change After validating errors if édit text if you use edit text and set error for birthday ...
Upvotes: 0