One.
Google or Baidu search, in the input keyword will appear in the automatic search prompt content, similar to the following effect, input B appears to contain the relevant term B
Two. Layout code
<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical" > <AutocompletetextviewAndroid:id= "@+id/autotext"Android:layout_width= "Match_parent"Android:layout_height= "60DP"Android:layout_margintop= "10DP" /></LinearLayout>
Autocompletetextview Layout Code
Above is the layout code of the above effect, using the Autocompletetextview component
Three. Setting up a data source
Using Autocompletetextview here also needs to arrayadapter<t> this class
Public classPicactivityextendsActivity {PrivateString[] Items={ "AB", "DB", "ADG", "Dbee", "Adre", "Ayrtr", "Btee", "BDW", "Bt45", "Aire", "VFDR", "434" }; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_pic); Autocompletetextview AutoText=(Autocompletetextview) Findviewbyid (R.id.autotext); Arrayadapter<String> adapter=NewArrayadapter<string> ( This, Android. R.layout.simple_dropdown_item_1line, items); Autotext.setadapter (adapter); Autotext.setthreshold (1); }}Data Source Settings
android--Automatic Search Tips