Android learning notes-autocompletetextview

Source: Internet
Author: User

<1> Introduction

Google or Baidu is often used when we access the internet. If we enter the information we want in the input box, other prompts related to it will appear, which is very convenient. This effect is implemented using autocompletetextview in Android.

Autocompletetextview is an editable text view. When you type it, the suggestion information is displayed automatically.

The suggestion list is displayed in the drop-down list box. You can select an item to replace the content in the edit box.

When you click Enter or click Enter, the drop-down list automatically disappears.

The recommended list is the data obtained from a data adapter.

 

<2> example

Package xiaosi. autocompletetextview; import android. app. activity; import android. OS. bundle; import android. widget. arrayadapter; import android. widget. autocompletetextview; public class autocompletetextviewactivity extends activity {private autocompletetextview = NULL; private final string [] citys = new string [] {"Belgium", "France", "Italy ", "Germany", "Spain", "sppp", "itaggg"};/** called when the activity is first created. * // @ override public void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. main); autocompletetextview = (autocompletetextview) findviewbyid (R. id. auto); // configure and set javasarrayadapter <string> arrayadapter = new arrayadapter <string> (autocompletetextviewactivity. this, android. r. layout. simple_dropdown_item_1line, citys); // autocompletetextview. setadapter (arrayadapter );}}

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.