If you need to enter an example table in the text box, you can select a prompt for each element in the input list. The previous AutoCompleteTextView only supports the prompt drop-down box when you enter the first element, in this case, you can use MultiAutoCompleteTextView. MultiAutoCompleteTextView is a subclass of AutoCompleteTextView. It supports substrings matching input strings. substrings are separated by separators (which can be specified by setTokenizer), for example, separated by commas.
This example shows how to use MultiAutoCompleteTextView. when you enter a country name in the text box, you can display the country name box multiple times. Country names are separated by commas:
[Java]
ArrayAdapter <String> adapter = new ArrayAdapter <String> (this,
Android. R. layout. simple_dropdown_item_1line, COUNTRIES );
MultiAutoCompleteTextView textView
= (MultiAutoCompleteTextView) findViewById (R. id. edit );
TextView. setAdapter (adapter );
TextView. setTokenizer (new MultiAutoCompleteTextView. CommaTokenizer ());
ArrayAdapter <String> adapter = new ArrayAdapter <String> (this,
Android. R. layout. simple_dropdown_item_1line, COUNTRIES );
MultiAutoCompleteTextView textView
= (MultiAutoCompleteTextView) findViewById (R. id. edit );
TextView. setAdapter (adapter );
TextView. setTokenizer (new MultiAutoCompleteTextView. CommaTokenizer ());
You can
You can use "," as the separator of the sub-string. To use other characters, you can implement MultiAutoCompleteTextView. Tokenizer to customize a Tokenizer.
Author: mapdigit