Android------autocompletetextview

Source: Internet
Author: User

Autocompletetextview can realize when the user input information automatically prompt function, but Autocompletetextview can only prompt once, and Multiautocompletetextview can also realize the function of information hint, And it is separated by commas to implement multiple hints.


Activity_main.xml:


<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools "android:layout_width=" fill_parent "android:layout_height=" Fill_parent "Android:orienta tion= "vertical" android:paddingbottom= "@dimen/activity_vertical_margin" android:paddingleft= "@dimen/activity_ Horizontal_margin "android:paddingright=" @dimen/activity_horizontal_margin "android:paddingtop=" @dimen/activity_ Vertical_margin "tools:context=" com.example.autocompletetextviewdemo.MainActivity "> <textview android:    Layout_width= "Fill_parent" android:layout_height= "wrap_content" android:text= "Autocompletetextview"/> <autocompletetextview android:id= "@+id/autotext" android:layout_width= "Fill_parent" android:layou t_height= "Wrap_content"/> <textview android:layout_width= "fill_parent" android:layout_height= "wrap _content "android:text=" Multiautocompletetextview "/> <multiautocompletetextview android:id= "@+id/mul" android:layout_width= "Fill_parent" Andro id:layout_height= "Wrap_content"/></linearlayout>


Mainactivity.java:


Import Android. R.anim;import android.app.activity;import android.os.bundle;import Android.view.menu;import android.view.MenuItem; Import Android.widget.adapter;import Android.widget.arrayadapter;import Android.widget.AutoCompleteTextView; Import Android.widget.multiautocompletetextview;public class Mainactivity extends Activity {private Autocompletetextview autocompletetextview;private Multiautocompletetextview multiautocompletetextview;@ overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview ( R.layout.activity_main); Autocompletetextview = (Autocompletetextview) Findviewbyid (R.id.autotext); String auto[] = new string[] {Computer Academy, School of Computer Science and technology, Google, GoogleMap};//The second parameter represents the drop-down style of the adapter arrayadapter<string > adapter = new arrayadapter<string> (Mainactivity.this, Android. R.layout.simple_dropdown_item_1line,auto); Autocompletetextview.setadapter (adapter); Multiautocompletetextview = ( Multiautocompletetextview) Findviewbyid (R.id.mul);Multiautocompletetextview.setadapter (adapter); Multiautocompletetextview.settokenizer (new Multiautocompletetextview.commatokenizer ());//complete the Split function for the option, split with a comma}}





Android------autocompletetextview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.