Auto Complete Text View | Android Developers

Description :

If you want to get suggestions, when you type in an editable text field, you can do this via AutoCompleteTextView. It provides suggestions automatically when the user is typing. The list of suggestions is displayed in a drop-down menu from which the user can choose an item to replace the content of the edit box with.

In order to use AutoCompleteTextView, you have to first create an AutoCompletTextView Field.

Syntax :








  android:ems="10" >

After that, you have to get a reference of this text view in java. Its syntax is given below.

private AutoCompleteTextView actv;

actv = (AutoCompleteTextView) findViewById(;

Methods :

1) getAdapter()

This method returns a filterable list adapter used for auto completion

2) getCompletionHint()

This method returns optional hint text displayed at the bottom of the the matching list

3 ) getDropDownAnchor()

This method returns returns the id for the view that the auto-complete drop down list is anchored to.

4) getListSelection()

This method returns the position of the dropdown view selection, if there is one

5) isPopupShowing()

This method indicates whether the popup menu is showing

6) setText(CharSequence text, boolean filter)

This method sets text except that it can disable filtering

7) showDropDown()

This method displays the drop down on screen.

Steps for creating autocomplete text view :

Step 1:    You will use Android Studio to create an Android application under a package

Step 2 :    Modify src/ file to add AutoCompleteTextView code

Step 3 :   Modify layout XML file res/layout/activity_main.xml add any GUI component if required.

Step 4:   Run the application and choose a running android device and install the application on it and verify the results.