This is popup for time picker.
when I click on keyboard icon it's showing like below screen.
I am using localization in our APP and below code I have written to open Time picker Popup
private fun openTimePickerDialog(datetime: String) {
val mHour: Int = datetime.substring(8, 10).toInt()
val mMinute: Int = datetime.substring(10, 12).toInt()
setDefaultLanguage()
Log.i("TAG", "openTimePickerDialog: $mHour $mMinute")
val timePickerDialog = TimePickerDialog(
activity,
{ _, hourOfDay, minute ->
var selectedMinute = minute.toString()
var selectedHour = hourOfDay.toString()
if (minute < 10) {
selectedMinute = "0$selectedMinute"
}
if (hourOfDay < 10) {
selectedHour = "0$selectedHour"
}
isClickedDate = ""
val date: String = datetime.substring(0, 8)
val time = selectedHour + selectedMinute + "00"
Log.i("TAG", "onTimeSet: $date$time")
roveR3SettingFragmentViewModel.setDateTime(date + time)
// txtTime.setText(hourOfDay + ":" + minute);
}, mHour, mMinute, false
)
timePickerDialog.setButton(
DatePickerDialog.BUTTON_POSITIVE,
getString(R.string.ok),
timePickerDialog
)
timePickerDialog.setButton(
DatePickerDialog.BUTTON_NEGATIVE,
getString(R.string.txt_cancel),
timePickerDialog
)
timePickerDialog.show()
}
private fun setDefaultLanguage() {
if (appPreference.appLanguage == LANGAUGE_ES) {
val locale1 = Locale("en")
Locale.setDefault(locale1)
val config = requireContext().resources.configuration
config.setLocale(locale1)
requireContext().createConfigurationContext(config)
} else if (appPreference.appLanguage == LANGAUGE_ES) {
val locale1 = Locale("ja")
Locale.setDefault(locale1)
val config = requireContext().resources.configuration
config.setLocale(locale1)
requireContext().createConfigurationContext(config)
}
}
Can any one please help me how to fix the language issue which is coming when i click on keyboard icon of time picker dialogue. I want it in english language I have selected it for English only other all thing coming in english but time picker is coming in Spanish language. Thanks.