Edit text (EditText)

Source: Internet
Author: User

Today to introduce to you is a simple edit text box;

Let's take a look at its basic properties:

1.Activity

 Public classEdittextactivityextendsActivity {PrivateEditText Nameedittext; PrivateEditText Passwordedittext; PrivateEditText Ageedittext; Privatebutton button;//Edit Text@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);                Setcontentview (R.layout.edit_text); Nameedittext=(EditText) Findviewbyid (R.id.nameedittextid); Passwordedittext=(EditText) Findviewbyid (R.id.passwordedittextid); Ageedittext=(EditText) Findviewbyid (R.id.ageedittextid); Button=(Button) Findviewbyid (R.id.buttonid); Button.setonclicklistener (NewView.onclicklistener () { Public voidOnClick (View v) {//get the name, password, age you enteredString name =Nameedittext.gettext (). toString (). Trim (); String Password=Passwordedittext.gettext (). toString (). Trim (); String agestring=Ageedittext.gettext (). toString (). Trim (); //for prompt MessagesToast.maketext (edittextactivity. This, "Name=" +name+ "\r\npassword=" +password+ "\r\nage=" +agestring, Toast.length_long). Show ();            }        }); }}

2.xml file:

<?xml version= "1.0" encoding= "Utf-8"?><!--text edit--><linearlayout xmlns:android= "/http/ Schemas.android.com/apk/res/android "Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "Vertical"android:padding= "5DP" > <TextView android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:text= "Name:"android:textsize= "20sp"/> <EditText Android:id= "@+id/nameedittextid"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:hint= "Please enter name"/> <TextView android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:text= "Password:"android:textsize= "20sp"/> <EditText Android:id= "@+id/passwordedittextid"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:hint= "Please enter password"Android:inputtype= "Textpassword"/> <TextView android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:text= "Age:"android:textsize= "20sp"/> <EditText Android:id= "@+id/ageedittextid"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:hint= "Please enter age"Android:inputtype= "Number"Android:maxlength= "3"/> <TextView android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:text= "Not Editable"android:textsize= "20sp"/> <EditText android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:editable= "false"Android:hint= "The content here cannot be changed"/> <TextView android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:text= "Cannot get focus (nor can edit)"android:textsize= "20sp"/> <EditText android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"android:focusable= "false"Android:hint= "This input box does not get focus"/> <Button Android:id= "@+id/buttonid"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Show user-filled information"/></linearlayout>

3. as follows:

Edit text (EditText)

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.