This example describes the basic usage of the Android Autocompletetextview control. Share to everyone for your reference, specific as follows:
When the input part of the content will have related suggestions, similar to the Baidu hint information
1. Declare a autocompletetextview in the layout file
<autocompletetextview
android:id= "@+id/autocomplete_country"
android:layout_width= "Fill_parent"
android:layout_height= "wrap_content"
android:layout_marginleft= "5DP"
/>
2, the definition of a hint entry style, in the layout directory to establish list_item.xml files
<?xml version= "1.0" encoding= "Utf-8"?> <textview xmlns:android=
"http://schemas.android.com/apk/" Res/android "
android:layout_width=" fill_parent "
android:layout_height=" Fill_parent "
android: padding= "10DP"
android:textsize= "16sp"
android:textcolor= "#000" >
</TextView>
3, it needs to use Arrayadapter to provide data
public void Setautocompletetextview () {
Autocompletetextview = (autocompletetextview) Findviewbyid ( R.id.autocomplete_country);
Countries is an array that Autocompletetextview matches the contents of the array with the input of the user and then displays to prompt the user
//r.layout.list_item to display the style
of the content displayed by the hint message arrayadapter<string> arrayadapter = new Arrayadapter<string> (this, R.layout.list_item, COUNTRIES);
Autocompletetextview.setadapter (Arrayadapter);
}
Note: Countries is an array type
4, the Autocompletetextview and Arrayadapter link up
For more information on Android-related content readers can view the site topics: "Android File Operation tips Summary", "Android programming development of the SD card operation Summary", "Android Development introduction and Advanced Course", "Android Resources Operating Skills summary", " Android View tips Summary and a summary of the use of Android controls
I hope this article will help you with the Android program.