android--Automatic Search Tips

Source: Internet
Author: User

One.

Google or Baidu search, in the input keyword will appear in the automatic search prompt content, similar to the following effect, input B appears to contain the relevant term B

Two. Layout code

<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical" >        <AutocompletetextviewAndroid:id= "@+id/autotext"Android:layout_width= "Match_parent"Android:layout_height= "60DP"Android:layout_margintop= "10DP"        /></LinearLayout>
Autocompletetextview Layout Code

Above is the layout code of the above effect, using the Autocompletetextview component

Three. Setting up a data source

Using Autocompletetextview here also needs to arrayadapter<t> this class

 Public classPicactivityextendsActivity {PrivateString[] Items={            "AB",            "DB",            "ADG",            "Dbee",            "Adre",            "Ayrtr",            "Btee",            "BDW",            "Bt45",            "Aire",            "VFDR",            "434"    }; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);                Setcontentview (R.layout.activity_pic); Autocompletetextview AutoText=(Autocompletetextview) Findviewbyid (R.id.autotext); Arrayadapter<String> adapter=NewArrayadapter<string> ( This, Android.                R.layout.simple_dropdown_item_1line, items);        Autotext.setadapter (adapter); Autotext.setthreshold (1); }}
Data Source Settings

android--Automatic Search Tips

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.