如何修复时间选择器对话框显示西班牙语的问题
时间选择器键盘界面语言异常问题
这是时间选择器的弹窗:
点击键盘图标后,显示如下界面:
我们的APP支持本地化功能,以下是打开时间选择器弹窗的代码:
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) } }
我已将应用语言设置为英文,其他界面均正常显示英文,但点击时间选择器对话框的键盘图标后,界面却显示为西班牙语,求解决方法,谢谢。
内容的提问来源于stack exchange,提问作者MARSH
相关产品推荐
相关产品推荐

