Figen Güngör Figen Güngör - 3 months ago 17
Android Question

AutoCompleteTextView doesn't work when I enter first character

My AutoCompleteTextView doesn't work when I enter first character in textbox but starts showing dropdown when I enter second character. What could be the reason?

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

Answer

You will need to set the completionThreshold property of your autoCompleteView to 1.

<AutoCompleteTextView 
    android:id="@+id/someID" 
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:completionThreshold="1" />

Or to do it dynamically use

mAutoCompleteTextView.setThreshold(1)
Comments