Android ApiDemos example resolution (104): Views-& gt; Auto Complete-& g

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.