Android Base Top5_1:autocompletetextview Auto-complete text box

Source: Internet
Author: User

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

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.