Android Tutorial

(avery) #1
Android Tutorial 175

Using AutoCompleteTextView (left) and
MultiAutoCompleteTextView (right).

Both of the auto-complete text editors use an adapter to get the
list of text that they use to provide completions to the user. This
example shows how to provide an AutoComplete TextView for the
user that can help them type some of the basic colors from an
array in the code:

final String[] COLORS = {
“red”, “green”, “orange”, “blue”, “purple”,
“black”, “yellow”, “cyan”, “magenta” };
ArrayAdapter adapter =
new ArrayAdapter(this,
android.R.layout.simple_dropdown_item_1line,
COLORS);
AutoCompleteTextView text = (AutoCompleteTextView)

Free download pdf