androidautocompletetextview

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

Solution

  • 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 for doing it dynamically through code use

    mAutoCompleteTextView.setThreshold(1)
    

    Happy Coding :)