。。。 Baidu on the search for such a paragraph. Understand the purpose of the three parameters of the Arrayadapter
1. This small example is to display an array, we use Arrayadapter, array adapter, data type <> is string type, data type can also be other including object type
2. arrayadapter<string> arrayadapter = new Arrayadapter<string> (Arraylistdemo.this, Android. R.layout.simple_list_item_1,adapterdata);
This code is to create an array adapter code, there are three parameters, the first parameter is the context, is the current activity, the second parameter is the Android SDK in its own built-in layout, it has only one textview, This parameter indicates that the layout of each piece of data in our array is this view, that is, each piece of data is displayed on the view, and the third parameter is the data we want to display. The ListView iterates through each of the data in the Adapterdata according to these three parameters, reads one, displays the layout corresponding to the second parameter, thus forming the ListView we see.
Adapterview function
A adapter object serves as a bridge between the Adapterview and the view underlying data, providing access to the dataitems, and is responsible for rendering to the corresponding view for each data.
Seems to understand the adapter is to do what use ... The feeling is that the data in the array or list is converted into a view ... This is easy to understand ...
The following code: is to automatically complete the text box
<LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical"><!--defines an AutoComplete text box, specifying that a character is entered to prompt -<AutocompletetextviewAndroid:id= "@+id/auto"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:completionhint= "Please select the book you Like"Android:dropdownhorizontaloffset= "10SP"Android:completionthreshold= "1" /><!--Define a Multiautocompletetextview -<MultiautocompletetextviewAndroid:id= "@+id/mauto"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:completionthreshold= "1" /></LinearLayout>
PackageCom.example.autocompletetv;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.widget.ArrayAdapter;ImportAndroid.widget.AutoCompleteTextView;ImportAndroid.widget.MultiAutoCompleteTextView; Public classMainactivityextendsActivity {Autocompletetextview ACTV; Multiautocompletetextview Mauto; //defines a character array as the hint textString[] Books=Newstring[]{"Java Handouts", "Ajax Handouts", "XML Handouts", "Android Handout" }; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); //creates a arrayadapter, encapsulates an arrayArrayadapter<string> aa=NewArrayadapter<string> ( This, Android. R.layout.simple_dropdown_item_1line, books); ACTV=(Autocompletetextview) Findviewbyid (R.id.auto); Actv.setadapter (AA); Mauto=(Multiautocompletetextview) Findviewbyid (R.id.mauto); Mauto.setadapter (AA); //set the delimiter for MultiautocompletetextviewMauto.settokenizer (NewMultiautocompletetextview.commatokenizer ()); } }