First look at the role of each package in an Android project
Here are a few of the most frequently used controls:
1. TextView Show text box controls
2. EditText Enter text box
TextView controls often use 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 controls often use 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 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 you enter text, you can display popular information that matches the content.
Often use attributes such as ID,width,height , and so on with other controls
Unique properties:
android:completionthreshold ="2"---- Set the input number of characters when you actively match
Multiautocompletetextview can support multiple values (in the case of multiple input), separated by a delimiter, and when each value is selected to enter the value again, will be active to match, can be used to send text messages, e-mail to choose the type of contact.
Properties are basically the same as Autocompletetextview . When using Multiautocompletetextview , you need to set a separator, which is the symbol to cut multiple inputs. Can be set using settokenzier () .
Like what:
Mxtx.settokenizer (newMultiautocompletetextview.commatokenizer ());
The
needs to be bound to the listener when using Autocompletetextview and Multiautocompletetextview, such as the following:
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