输入第一个字符时,AutoCompleteTextView不起作用

Fig*_*gör 11 android autocompletetextview

当我在文本框中输入第一个字符但在输入第二个字符时开始显示下拉列表时,我的AutoCompleteTextView不起作用.可能是什么原因?

<AutoCompleteTextView
    android:id="@+id/autocomplete_name"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_weight="7"
    android:background="@drawable/edittextback"
    android:ems="10"
    android:textSize="15sp"
    android:hint="@string/codehint"
    android:textColorHint="@color/hintgrey"
    android:dropDownWidth="fill_parent"
    android:paddingRight="30dp"
    android:paddingLeft="10dp"
    android:singleLine="true"
    android:ellipsize="end"
/>
Run Code Online (Sandbox Code Playgroud)

nob*_*alG 49

容易:D

您需要将您的completionThreshold属性设置autoCompleteView为1.

<AutoCompleteTextView 
    android:id="@+id/someID" 
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:completionThreshold="1" />
Run Code Online (Sandbox Code Playgroud)

或者通过代码使用动态地完成它

mAutoCompleteTextView.setThreshold(1)
Run Code Online (Sandbox Code Playgroud)

快乐编码:)