Android common control Autocompletetextview, Spinner

Source: Internet
Author: User

Overview

1, Autocompletetextview: Compared to the ordinary Textview,autocompletetextview feature is the ability to automatically prompt text, it can be loaded through the Setadapter () method adapter.
2, Spinner: A drop-down list.

Knowledge Content Autocompletedtextview

Layout file

<Relativelayout xmlns:android="Http://schemas.android.com/apk/res/android"                Xmlns:tools="Http://schemas.android.com/tools"                Android:layout_width="Match_parent"                Android:layout_height="Match_parent"                Android:paddingleft="@dimen/activity_horizontal_margin"                Android:paddingright="@dimen/activity_horizontal_margin"                Android:paddingtop="@dimen/activity_vertical_margin"                Android:paddingbottom="@dimen/activity_vertical_margin"                Tools:context=". Mainactivity ">    <autocompletetextviewandroid:id="@+id/auto_complete_textview"android: Layout_width="Match_parent"android:layout_height="Wrap_content"android: TextColor="#2af"/>                                </relativelayout>

Java section

 Public  class mainactivity extends Activity {    PrivateAutocompletetextview Mcompletetextview;PrivateArrayadapter<string> Marrayadapter;PrivateString[] Mdata = {"Layout_linear","Layout_relative","Layout_absolute","Text_view","Button_image","Button_radio"};@Override    protected void onCreate(Bundle savedinstancestate) {Super. OnCreate (Savedinstancestate);        Setcontentview (r.layout.spinner_layout);        Mcompletetextview = (Autocompletetextview) Findviewbyid (R.id.auto_complete_textview); Marrayadapter =NewArrayadapter<string> ( ThisAndroid.        R.layout.test_list_item,mdata);    Mcompletetextview.setadapter (Marrayadapter); }}

Results Demo:

Spinner

Layout file

<?xml version= "1.0" encoding= "Utf-8"?><linearlayout xmlns:android="Http://schemas.android.com/apk/res/android"  Android:orientation="vertical"android:layout_width="Match_parent"android: Layout_height="Match_parent">                                              <Spinnerandroid:id="@+id/spinner"android:layout_width= "Match_parent" android:layout_height="Wrap_content">                            </Spinner></linearlayout>

Java section

 Public  class mainactivity extends Activity {    PrivateSpinner Mspinner;PrivateString[] Mdata = {"Layout_linear","Layout_relative","Layout_absolute","Text_view","Button_image","Button_radio"};@Override    protected void onCreate(Bundle savedinstancestate) {Super. OnCreate (Savedinstancestate);        Setcontentview (R.layout.activity_main);        Mspinner = (Spinner) Findviewbyid (R.id.spinner);    Mspinner.setadapter (Marrayadapter); }}

Results Demo

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android common control Autocompletetextview, Spinner

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.