<1> Introduction
Google or Baidu is often used when we access the internet. If we enter the information we want in the input box, other prompts related to it will appear, which is very convenient. This effect is implemented using autocompletetextview in Android.
Autocompletetextview is an editable text view. When you type it, the suggestion information is displayed automatically.
The suggestion list is displayed in the drop-down list box. You can select an item to replace the content in the edit box.
When you click Enter or click Enter, the drop-down list automatically disappears.
The recommended list is the data obtained from a data adapter.
<2> example
Package xiaosi. autocompletetextview; import android. app. activity; import android. OS. bundle; import android. widget. arrayadapter; import android. widget. autocompletetextview; public class autocompletetextviewactivity extends activity {private autocompletetextview = NULL; private final string [] citys = new string [] {"Belgium", "France", "Italy ", "Germany", "Spain", "sppp", "itaggg"};/** called when the activity is first created. * // @ override public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. main); autocompletetextview = (autocompletetextview) findviewbyid (R. id. auto); // configure and set javasarrayadapter <string> arrayadapter = new arrayadapter <string> (autocompletetextviewactivity. this, android. r. layout. simple_dropdown_item_1line, citys); // autocompletetextview. setadapter (arrayadapter );}}