AutocompleteTextview in Android – Complete Tutorial

AutocompleteTextview in Android – Implementation and Overview

AutocompleteTextview in short, helps the user complete the text when entered into a EditText. If you have read my TextView or ListView, you can guess how we are going to do this.

We will need to declare AutocompleteTextview with a simple AutocompleteTextview XML tag.

    android:text="Text Here"/>

AutocompleteTextview Properties


android:dropDownHeight – Specifies the height of the dropdown.

android:dropDownAnchor – View to anchor the auto-complete dropdown to.

android:completionHint – The hint displayed in the drop down menu. Make sure you have this set, inorder to provide better understanding that the view is actually a drop down view

android:completionThreshold – Tthe number of characters that the user must type before completion suggestions are displayed in a drop down menu. Threshold is important when you are serving data from the database

Think of lots of data you have to show in the drop down. The threshold can help you categorise the data a bit faster. Play around with this property to balance the UI experience and the speed with which the data is rendered.

android:popupBackground – This sets the background. Can be color or a image. Be careful when you set this property, sometimes simple is better!!

android:dropDownSelector – This is the selector in a drop down list.

AutocompleteTextview Implementation

Implement the XML document like below.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""
        android:text="Text Here"
        android:completionHint="Complete Text"/>

package wolfsoft.ozzon;

import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;

public class AutocompleteActivity extends AppCompatActivity {
    AutoCompleteTextView autoCompleteTextView;
    protected void onCreate(Bundle savedInstanceState) {
        String[] stringOfArray = { "autocomplete,text1", "Beta complete","Lines of code",
                "Lint based framework", "automatic"};
        autoCompleteTextView = (AutoCompleteTextView) findViewById(;
        ArrayAdapter<String> adapter = new ArrayAdapter<String>
                (this,android.R.layout.select_dialog_item, stringOfArray);

The final screen looks like this:


You can take a look here to learn about firebase and pulling data from there.

It is very useful when you have lot of data that you want to create a autocompletetextview. Learn to play around with the data controllers and also various adapters to learn how you can interpret the data.

Check here for additional tips for material design inspiration.

“Learn and Be Curious”


Leave a Comment