可编辑微调器在Android程序中无法正常工作?

可编辑微调器在Android程序中无法正常工作?,android,android-spinner,Android,Android Spinner,请找到下面的scrren快照 这里,我有一个带有EditText的微调器。用户可以选择微调器项,也可以输入自定义数据(如用户在EditText中输入的100)。因此,我可以根据位置获取微调器选择的数据。但是,当我试图在微调器中的edittext中输入任何数据时,它的光标会自动转到edittext下面 所以请帮助任何人解决这个问题。多谢各位 我已经用EditText为Spinner编写了以下代码 ArrayAdapter<CharSequence> adapter1 = ArrayA

请找到下面的scrren快照

这里,我有一个带有EditText的微调器。用户可以选择微调器项,也可以输入自定义数据(如用户在EditText中输入的100)。因此,我可以根据位置获取微调器选择的数据。但是,当我试图在微调器中的edittext中输入任何数据时,它的光标会自动转到edittext下面

所以请帮助任何人解决这个问题。多谢各位

我已经用EditText为Spinner编写了以下代码

ArrayAdapter<CharSequence> adapter1 = ArrayAdapter.createFromResource( 
                this, R.array.my_array, R.layout.custom_spinner); 
        adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
        spinner_distance.setAdapter(adapter1);
ArrayAdapter适配器1=ArrayAdapter.createFromResource(
这个,R.array.my_array,R.layout.custom_微调器);
adapter1.setDropDownViewResource(android.R.layout.simple\u微调器\u下拉菜单\u项);
微调器距离设置适配器(适配器1);
在custom_spinner.xml中

    <?xml version="1.0" encoding="utf-8"?>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:id="@+id/custom_edit"

    android:hint="Enter"
    android:singleLine="true"
    android:maxLength="3">
    <requestFocus />
    </EditText>

使用自动完成文本视图

   ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( 
            this, R.array.my_array, android.R.layout.simple_list_item_1);  
   AutoCompleteTextView tv=   (AutoCompleteTextView)findViewById(R.id.autoCompleteTextView);  
       tv.setThreshold(1);
       tv.setAdapter(adapter);
ArrayAdapter=ArrayAdapter.createFromResource(
这个,R.array.my\u array,android.R.layout.simple\u list\u item\u 1);
AutoCompleteTextView tv=(AutoCompleteTextView)findViewById(R.id.AutoCompleteTextView);
设置阈值(1);
电视设置适配器(适配器);
在xml文件中替换

 <Spinner ........./> 

用下面的代码

    <AutoCompleteTextView  
    android:id="@+id/autoCompleteTextView"  
    android:layout_width="match_parent"  
    android:layout_height="wrap_content"  
    android:padding="5dp"   
    android:ems="10"  
    android:text="100">  
    <requestFocus />  
    </AutoCompleteTextView>

您可以试试这个

((EditText)微调器_distance.getChildAt(0)).getText()


由于微调器项本身是一个edittext,因此这将为您提供一个edittext值。

请参考您在此处声明自动完成布局的回答ArrayAdapter=ArrayAdapter.createFromResource(此,R.array.my_数组,android.R.layout.simple_list_项1);AutoCompleteTextView tv=(AutoCompleteTextView)findViewById(R.id.AutoCompleteTextView);设置阈值(1);电视设置适配器(适配器);只需将您的微调器替换为AutoCompleteTextView@Siva PolamSo,这就是全部,我们只显示AutoCompleteTextView,对吗?不是纺纱机。但我们需要带有可编辑@Nooh的微调器