Android AutoCompleteTextView(setText)和fragment.detach().attach()

Android AutoCompleteTextView(setText)和fragment.detach().attach(),android,kotlin,fragment,autocompletetextview,Android,Kotlin,Fragment,Autocompletetextview,我制作应用程序并添加此功能更改语言。我更改了使用的main活动的片段中的语言 ... val locale = Locale("es") Locale.setDefault(locale) val configuration = Configuration() configuration.locale = locale this.resources.updateConfiguration(conf

我制作应用程序并添加此功能更改语言。我更改了使用的main活动的片段中的语言

...
        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
... 
在片段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
    ...
。。。
val listSpeed=Scales.initSpeedsList().map{String.format(“%.1f”,it)}
val适配器速度:ArrayAdapter=ArrayAdapter(
requireContext(),
R.布局。列表\项目\比例,
列表速度)
bindingScale.editSpeed.setAdapter(适配器速度)
bindingScale.editSpeed.setText(bindingScale.editSpeed.adapter.getItem(1.toString(),false)//1
...
如果我注释掉第1行(setText),则该字段为空,下拉列表由5行组成(应为5行)。如果第1行未注释,则该字段已填充,下拉列表为一行或根本没有。如果我不执行supportFragmentManager.beginTransaction().detach(scaleFragment).attach(scaleFragment).commit(即,我不将页面翻译成另一种语言),则一切正常-填写字段,下拉列表包含所有必要的选项

     <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>


我做错了什么。对不起,我的英语不好

我没有考虑AutoCompleteTextView根据输入的值过滤列表的内容。有必要断开适配器中的滤清器。如果未禁用过滤器,则当重新绘制片段时,它将仅在适配器中显示满足过滤条件的结果