1 <linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
2Xmlns:tools= "Http://schemas.android.com/tools"3Android:layout_width= "Match_parent"4android:orientation= "Vertical"5android:layout_height= "Match_parent"6tools:context= "Com.example.top5_1.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= "Word Search complement Demo"/> -<Autocompletetextview -Android:id= "@+id/ed" -Android:layout_width= "Fill_parent" +android:layout_height= "Wrap_content" -Style= "@android: Attr/textviewstyle" +Android:hint= "Please enter the word"
Set to start with a second character prompt AAndroid:completionthreshold= "2" atandroid:layout_margintop= "10DP" - -/></linearlayout>
Java:
1 Public classMainactivityextendsactivity{2 PrivateAutocompletetextview Act;3 //set up a data source4 Private Static FinalString[] words={"abc", "ACD", "Ade"};5 6 protected voidonCreate (Bundle savedinstancestate) {7 Super. OnCreate (savedinstancestate);8 Setcontentview (r.layout.activity_main);9act=(Autocompletetextview) Findviewbyid (R.id.ed);Ten //assign a data source to a text box OneArrayadapter<string> aa=NewArrayadapter<string> ( This, A Android. R.layout.simple_dropdown_item_1line,words); - act.setadapter (AA); -};
Android Base Top5_1:autocompletetextview Auto-complete text box