Complete AutoCompleteTextView example in Android (1)

Source: Internet
Author: User

MainActivity is as follows:

Package cc. testautocompletetextview; import cc. testautocompletetextview1.R; import android. OS. bundle; import android. widget. arrayAdapter; import android. widget. autoCompleteTextView; import android. app. activity;/*** Demo Description * Complete example of AutoCompleteTextView usage ** Note: * android: completionThreshold = "2" ** references: * Li Gang * Thank you very much */public class MainActivity extends Activity {private AutoCompleteTextView mAutoCompleteTextView; @ Overrideprotected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. main); init ();} private void init () {mAutoCompleteTextView = (AutoCompleteTextView) findViewById (R. id. autoCompleteTextView); String [] emails = new String [] {"111@126.com", "111@sina.com", "111@sohu.cn", "111@qq.com"}; ArrayAdapter
 
  
ArrayAdapter = new ArrayAdapter
  
   
(This, android. R. layout. simple_dropdown_item_1line, emails); mAutoCompleteTextView. setAdapter (arrayAdapter );}}
  
 


Main. xml is as follows:

     
          
 


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.