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 );}}