Can';t在Android中的AutoCompleteTextView中键入

Can';t在Android中的AutoCompleteTextView中键入,android,layout,autocompletetextview,Android,Layout,Autocompletetextview,我在布局中放置了一个AutoCompleteTextView,但我无法在其中写入任何可见的内容!我找不到解决这个问题的办法 以下是我的布局: <AutoCompleteTextView android:id="@+id/txtOccupation" android:layout_width="510dp" android:layout_height="40dp" android:layout_below="@+id/dateP

我在布局中放置了一个AutoCompleteTextView,但我无法在其中写入任何可见的内容!我找不到解决这个问题的办法

以下是我的布局:

<AutoCompleteTextView
        android:id="@+id/txtOccupation"
        android:layout_width="510dp"
        android:layout_height="40dp"
        android:layout_below="@+id/datePicker"
        android:layout_toRightOf="@id/lblOccupation"
        android:background="#FFFFFF"
        android:paddingTop="10dp"
        android:paddingBottom="10dp" />

用Xml表示。在这种情况下,completionThreshold=1意味着,在键入一个字母后,列表将显示,而您将其设置为2,如下所示

<AutoCompleteTextView
     android:id="@+id/autoCompleteTextView_search_location"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_gravity="center_horizontal"
     android:completionThreshold="1"
     android:imeOptions="actionDone"
     android:inputType="text"
     android:paddingLeft="10dp"
     android:singleLine="true"
     android:maxLength="20"
     android:textSize="22px" >
</AutoCompleteTextView>

在活动中,它应该实现TextWatcher。然后为此添加未实现的方法。并如下设置适配器

autoCompleteTextView_search_location.addTextChangedListener(this);
autoCompleteTextView_search_location.setAdapter(new ArrayAdapter<String>(this,
    android.R.layout.simple_dropdown_item_1line,occupations));
autoCompleteTextView\u search\u location.addTextChangedListener(此);
autoCompleteTextView\u search\u location.setAdapter(新的ArrayAdapter(此,
android.R.layout.simple_下拉列表_item_1line,职业);

请告诉我您的问题是否已解决。

用Xml表示。在这种情况下,completionThreshold=1意味着,在键入一个字母后,列表将显示,而您将其设置为2,如下所示

<AutoCompleteTextView
     android:id="@+id/autoCompleteTextView_search_location"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_gravity="center_horizontal"
     android:completionThreshold="1"
     android:imeOptions="actionDone"
     android:inputType="text"
     android:paddingLeft="10dp"
     android:singleLine="true"
     android:maxLength="20"
     android:textSize="22px" >
</AutoCompleteTextView>

在活动中,它应该实现TextWatcher。然后为此添加未实现的方法。并如下设置适配器

autoCompleteTextView_search_location.addTextChangedListener(this);
autoCompleteTextView_search_location.setAdapter(new ArrayAdapter<String>(this,
    android.R.layout.simple_dropdown_item_1line,occupations));
autoCompleteTextView\u search\u location.addTextChangedListener(此);
autoCompleteTextView\u search\u location.setAdapter(新的ArrayAdapter(此,
android.R.layout.simple_下拉列表_item_1line,职业);

告诉我您的问题是否已解决。

您的代码是正确的。“写任何看得见的东西”是什么意思?你的输入不可见吗?我的意思是我看不到我在文本视图中输入的内容,并且不会显示任何建议!您没有任何样式应用于
自动完成文本视图
,更改文本颜色等等。。?你的代码对我非常有效。你发布的代码在我的设备上非常有效。应该不会有任何问题。谢谢各位,我想这对我也会有用的。你们的代码是正确的。“写任何看得见的东西”是什么意思?你的输入不可见吗?我的意思是我看不到我在文本视图中输入的内容,并且不会显示任何建议!您没有任何样式应用于
自动完成文本视图
,更改文本颜色等等。。?你的代码对我非常有效。你发布的代码在我的设备上非常有效。应该不会有任何问题。谢谢各位,我想这对我也适用。但是如果我想在布局中添加微调器,我应该在布局中实现AdapterView.OnItemSelectedListener,我如何在我的活动代码中合并这两个实现?可能吗。例如,这个微调器:我很好奇。为什么要将
TextWatcher
添加到
AutoCompleteView
?但是如果我想在布局中添加微调器,我应该在布局中实现AdapterView.OnItemSelectedListener,我如何在我的活动代码中合并这两个实现?可能吗。例如,这个微调器:我很好奇。为什么要将
TextWatcher
添加到
AutoCompleteView