Add an Autocomplete Text Input

PDF for offline use
Sample Code:
Related SDKs:

Let us know how you feel about this

Translation Quality


This recipe shows how to use the AutoCompleteTextView.


  • Create a layout file that contains an AutoCompleteTextView, such as Main.axml in the example code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""

  • Use the Main.axml as the view for your activity:
SetContentView (Resource.Layout.Main);
  • Create a string array containing the options you would like to be autocompleted:
var autoCompleteOptions = new String[] { "Hello", "Hey", "Heja", "Hi", "Hola", "Bonjour", "Gday", "Goodbye", "Sayonara", "Farewell", "Adios" };
  • Use the array to populate an ArrayAdapter with the built-in SimpleDropDownItem1Line layout:
ArrayAdapter autoCompleteAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, autoCompleteOptions);
  • Find the instance of the AutoCompleteTextView in the layout and assign the ArrayAdapter:
var autocompleteTextView = FindViewById<AutoCompleteTextView>(Resource.Id.AutoCompleteInput);
autocompleteTextView.Adapter = autoCompleteAdapter;
  • When the control has focus and the user is typing, matching entries will automatically be displayed for them to choose from.

Additional Information

To use a much longer list of autocomplete options than the array in step 3, use the code below to load the list from a file:

// instead of the small array of greetings, use a large dictionary of words loaded from a file
Stream seedDataStream = Assets.Open(@"WordList.txt");
List<string> lines = new List<string>();

using (StreamReader reader = new StreamReader(seedDataStream)) {
    string line;
    while ((line = reader.ReadLine()) != null) {
string[] wordlist = lines.ToArray();
ArrayAdapter dictionaryAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, wordlist);
autocompleteTextView.Adapter = dictionaryAdapter;

The WordList.txt file is included in the example project.

Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.