Use of the AutoCompleteTextView Control Based on Android Studio development

Source: Internet
Author: User

Use of the AutoCompleteTextView Control Based on Android Studio development

If you enter the information we want to enter in the input box, other related prompts will appear. This effect is achieved in Android using AutoCompleteTextView. The AutoCompleteTextView control inherits from the TextView control and has its own properties:

 

AutoCompleteTextView common attributes
Android: completionHint Set the title of the prompt that appears in the drop-down menu
Android: completionThreshold Set the number of characters that the user must enter to display the prompt.
Android: dropDownHorizontalOffset Horizontal offset between text boxes in the drop-down menu. Align left with text box by default
Android: dropDownHeight Height of the drop-down menu
Android: dropDownWidth Width of the drop-down menu
Android: singleLine Single Row display
Android: dropDownVerticalOffset Vertical offset

 

I. Effects:

Ii. Code:

 

     
      
   
  
 

 

 

Package com. example. lhb. autocompletetextview; import android. app. searchableInfo; import android. support. v7.app. actionBarActivity; import android. OS. bundle; import android. view. menu; import android. view. menuItem; import android. widget. arrayAdapter; import android. widget. autoCompleteTextView; public class MainActivity extends ActionBarActivity {@ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_main); Search ();} private void Search () {String [] aut = new String [] {"Android", "Android software", "Android Project ", "Android Studio"}; ArrayAdapter
 
  
Adapter = new ArrayAdapter
  
   
(This, R. layout. abc_simple_dropdown_hint, aut); AutoCompleteTextView textView = (AutoCompleteTextView) findViewById (R. id. KeyWords); textView. setAdapter (adapter );}}
  
 


 

Related Article

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.