Android Infrastructure Components

Source: Internet
Author: User
<span id="Label3"></p><p><p><strong><span style="font-size: 18pt;">Basic components</span></strong></p></p><p><p><span style="font-size: 16px;"><strong>All of the controls can be created in Java code, and most of the properties correspond to the set and get methods, such as</strong></span></p></p><p><p><span style="font-size: 16px;">View view = new View (context Context) is contextual, is the activity parent class, typically passes in the current activity</span></p></p><p><p>1, TextView</p></p><p><p>Text SetText () GetText ()</p></p><p><p>TextColor text color #FFFFFF settextcolor (color.blue) gettextcolor ()</p></p><p><p>Textsize Text Size SP settextsize () gettextsize ()</p></p><p><p>Textsytle Text style without Java code (brush Drawing)</p></p><p><p>Gravity Text Alignment Center</p></p><p><p></p></p><p><p>2. Button</p></p><p><p>Inherit textview, owning all the properties and methods in the TextView</p></p><p><p>Enable=true can not point setenable ()</p></p><p><p></p></p><p><p>3, ImageView</p></p><p><p>SRC set front picture setimageresource (r.drawable.xxx);</p></p><p><p>ScaleType Picture Stretching Setscaletype (scaletype.xxx);</p></p><p><p>Adjustviewbounds Setadjustviewbounds (Boolean);</p></p><p><p></p></p><p><p>4, EditText</p></p><p><p>EditText is another important control that the program uses to interact with the user, allowing the user to enter and edit content in the control, and to process the content in the program</p></p><p><p>EditText inherited from textview, with all the properties and methods in TextView</p></p><p><p>Common Properties:</p></p><p><p>EMS Sets the width of the TextView to n characters</p></p><p><p>Maxlines Maximum number of rows displayed</p></p><p><p>Hint Hint language</p></p><p><p>Textcolorhint color of the cue language</p></p><p><p>MaxLength limit the number of input characters, such as setting 5, then you can enter only 5 kanji/alphanumeric/english letters</p></p><p><p>inputtype= "textpassword" Input type, ... 2, Set the password, number set digit (switch to digital soft keyboard)</p></p><p><p>Digits= "abcd" only allows the input of the ABCD character</p></p><p><p>singleline= "true" single-line Mode</p></p><p><p>Imeoptions set the ENTER key for the soft Keyboard. Available | set multiple</p></p><p><p>Normal default line break</p></p><p><p>Actiongo the soft keyboard below becomes "go" "goes" to the "go" according to the input method different</p></p><p><p>Actionsearch Soft Keyboard under "search" or magnifying glass</p></p><p><p>Actionsend Soft Keyboard under "send"</p></p><p><p>Actionnext soft keyboard below becomes "next"</p></p><p><p>Actiondone under the soft keyboard becomes "done", after clicking the cursor remains on the original input box, and the soft keyboard is closed</p></p><p><p>Events unique to EditText</p></p><p><p>File Change monitoring</p></p><p><p>Addtextchangelistener (new Watcher () {</p></p><p><p>@Override</p></p><p><p>public void ontextchanged (charsequence s, int start, int before,int Count) {</p></p><p><p>Callback this method when the text changes <span style="line-height: 1.5;">}</span></p></p><p><p><span style="line-height: 1.5;">@Override</span></p></p><p><p>public void beforetextchanged (charsequence s, int. start, int count,int after) {<span style="line-height: 1.5;">}</span></p></p><p><p><span style="line-height: 1.5;">@Override</span></p></p><p><p>public void aftertextchanged (Editable s) {<span style="line-height: 1.5;">}</span></p></p><p><p>});</p></p><p><p>Enter key to listen</p></p><p><p>Et.setoneditoractionlistener (new Oneditoractionlistener () {</p></p><p><p>@Override</p></p><p><p>public boolean oneditoraction (TextView v, int actionid, keyevent Event) {</p></p><p><p>processing, actiongid, Resource ID of the current event component, used to differentiate multiple edittext with the same listener</p></p><p><p>Event source, encapsulating the current action action</p></p><p><p>Return false;</p></p><p><p>}</p></p><p><p>});</p></p><p><p>    </p></p><p><p>    </p></p><p><p>Android Infrastructure Components</p></p></span>

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.