The first lesson of Android learning

Source: Internet
Author: User

First look at the role of each package in an Android project

Here are a few common controls:

1. TextView Show text box controls

2. EditText Enter text box

TextView Control Common Properties:

ID ---- the ID of the control

layout_width---- The width of the control

layout_height---- The height of the control

Text ---- textual content

textSize---- Text size

textcolor---- text color

background---- control background

EditText Control Common Properties

ID ---- the ID of the control

layout_width---- The width of the control

layout_height---- The height of the control

Text ---- textual content

textSize---- Text size

textcolor---- text color

background---- control background

hint---- input hint text

inputtype---- input text type

The width height of the control can be an optional value:

wrap_content: wraps the actual text content, that is, the font has how wide the width of the control.

match_parent: The current control fills the parent class container - A property value added after 2.3API

fill_parent: The current control fills a parent class container --- a property value before 2.3API

autocompletetextview and Multiautocompletetextview

Autocompletetextview dynamically matches the input content, such as Baidu search engine, when the input text can be displayed according to the content of popular information matching.

Common properties, such as ID,width,height , and so on, are the same as other controls

Unique properties:

android:completionthreshold ="2"---- set How many characters are entered automatically when you match

Multiautocompletetextview can support multiple values (in the case of multiple input), separated by a delimiter, and when each value is selected to re-enter the value will automatically go to match, can be used to send text messages, e-mail to select the type of contact.

Properties are basically the same as Autocompletetextview , you need to set a delimiter when using Multiautocompletetextview , that is, what symbol splits multiple inputs. Can be set using settokenzier () .

For example:

Mxtx.settokenizer (newMultiautocompletetextview.commatokenizer ());

You need to bind the listener when you use Autocompletetextview and Multiautocompletetextview, in the following steps:

Package Com.example.test;import Android.os.bundle;import Android.app.activity;import android.widget.ArrayAdapter; Import Android.widget.autocompletetextview;import Android.widget.multiautocompletetextview;public class Mainactivity extends Activity {private Autocompletetextview actextview;private string[] res = {"Beijing", "beijing1", "    Shan "," Shandong "," Shanxi "," Hebei "," Henan "," Hexi "};p rivate Multiautocompletetextview mxtx;        @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);        Setcontentview (R.layout.activity_main); /* First step: Initialize the control * Step two: Require an adapter (to fit the input of the text box) * Step three: Initialize the data source (to match what the text box entered) * Fourth step: Adapter and current AutoCo        Mpletetextview binding */Actextview = (Autocompletetextview) Findviewbyid (R.ID.AUTOCOMPLETETEXTVIEW1); arrayadapter<string> adapter = new Arrayadapter<string> (this, Android.        R.layout.simple_list_item_1, RES);      Actextview.setadapter (adapter);          MXTX = (Multiautocompletetextview) Findviewbyid (R.ID.MULTIAUTOCOMPLETETEXTVIEW1);        Mxtx.setadapter (adapter);    Set the comma as the delimiter Mxtx.settokenizer (New Multiautocompletetextview.commatokenizer ()); }        }


The first lesson of Android learning

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.