Activity:
1<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"2Xmlns:tools= "Http://schemas.android.com/tools"3Android:layout_width= "Match_parent"4android:layout_height= "Match_parent"5android:orientation= "Vertical"6tools:context= "Com.example.top5_2.MainActivity" >7 8<EditText9Android:layout_width= "Fill_parent"Tenandroid:layout_height= "Wrap_content" Oneandroid:paddingleft= "5DP" AAndroid:background= "#FFA500" -Android:textsize= "16SP" -android:drawableleft= "@drawable/ic_launcher" theandroid:text= "multi-match auto complement demo"/> -<Multiautocompletetextview -Android:id= "@+id/ed" -Android:layout_width= "Fill_parent" +android:layout_height= "Wrap_content" -Style= "@android: Attr/textviewstyle" +Android:hint= "Please enter the word" Aandroid:layout_margintop= "10DP" atAndroid:completionthreshold= "2" -/> -</LinearLayout>
Java:
1 Public classMainactivityextendsActivity {2 PrivateMultiautocompletetextview MCT;3 Private Static FinalString[] words={"abc", "ACD", "Ade"};4 @Override5 protected voidonCreate (Bundle savedinstancestate) {6 Super. OnCreate (savedinstancestate);7 Setcontentview (r.layout.activity_main);8 9mct=(Multiautocompletetextview) Findviewbyid (R.id.ed);TenArrayadapter<string> aa=NewArrayadapter<string> ( This, One Android. R.layout.simple_dropdown_item_1line,words); A mct.setadapter (AA); -Mct.settokenizer (NewMultiautocompletetextview.commatokenizer ()); - } the Public BooleanOncreateoptionsmenu (Menu menu) { - getmenuinflater (). Inflate (R.menu.main, menu); - return true; -}
Operating effect:
Android base Top5_2:multiautocompletetextview Multi-text auto-complete text box