I make app and add this function change language. I change language in fragment from MainActivity used
...
val locale = Locale("es")
Locale.setDefault(locale)
val configuration = Configuration()
configuration.locale = locale
this.resources.updateConfiguration(configuration, null)
...
supportFragmentManager.beginTransaction().
detach(scaleFragment).attach(scaleFragment).commit
...
in fragment CreateView
...
val listSpeed = Scales.initSpeedsList().map{String.format("%.1f", it)}
val adapterSpeed: ArrayAdapter<String> = ArrayAdapter(
requireContext(),
R.layout.list_item_scale,
listSpeed)
bindingScale.editSpeed.setAdapter(adapterSpeed)
bindingScale.editSpeed.setText(bindingScale.editSpeed.adapter.getItem(1).toString(), false)//1
...
if I comment out line 1 (setText), then the field is empty and the dropdown list consists of 5 lines (5 lines should be). if line 1 is uncommented, then the field is filled and the drop-down list is one line or nothing at all. if I don’t do supportFragmentManager.beginTransaction().detach(scaleFragment).attach(scaleFragment).commit(i.e. I don’t translate the page into another language) then everything works correctly - the field is filled in and the drop-down list contains all the necessary options
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/editSpeedLayout"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.ExposedDropdownMenu"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_marginTop="4dp"
android:hint="@string/speed_head"
app:layout_constraintEnd_toStartOf="@id/editVoltageLayout"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/textHeaderScale"
app:suffixText="@string/mm_per_sec">
<AutoCompleteTextView
android:id="@+id/editSpeed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="none" />
</com.google.android.material.textfield.TextInputLayout>
what am I doing wrong. Sorry for my English