Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"
/>
like image 843
Figen Güngör Avatar asked Oct 16 '14 12:10

Figen Güngör


2 Answers

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 :)

like image 128
nobalG Avatar answered Sep 28 '22 08:09

nobalG


use i java code

autoComplete.setThreshold(1);

or in xml

android:completionThreshold="1"
like image 29
Naveen Tamrakar Avatar answered Sep 28 '22 08:09

Naveen Tamrakar