EditText is very commonly used control for Android platform.
EditText means you can edit the text of the control.For example you are entering username and password to the system. EditText accept username and password. You have to type your username and password to the EditText control. Below is the design code of EditText
EditText control have some common property like
"id" : Property is uniquely identified of the control.
directly write
As like other control Gravity property set the position of EditText.
It can be placed center, button, top. Below is the example of to know how it
can be placed at the top of its parent layout.
code
output
EditText has some variety of nature of accepting the text. It can accept a single line text. Here is the example
EditText can accept multiple line of text, here is the example.
EditText connection password. Input type password property accept password.Here is the example.
You can design your EditText in variety of format. You can the font size, colour of font background ect. Here is the example.Here text size is 30sp and background color is #CA5100 and fore color is #CA5100.
EditText event handling is a very easy process. Below section show that how and even handle can be done.
EditText means you can edit the text of the control.For example you are entering username and password to the system. EditText accept username and password. You have to type your username and password to the EditText control. Below is the design code of EditText
<EditText
android:id="@+id/txt_user_name"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:hint="Please
enter username"
android:imeActionId="6"
android:maxLines="1"
android:singleLine="true"
android:textColor="#000000"
android:textSize="30sp"
android:background="#FFFFFF"
android:gravity="center"
/>
EditText control have some common property like
- id
- layout_width
- layout_height
- hints
- gravity
- textcolor
- singleLine
- backgound
"id" : Property is uniquely identified of the control.
"text" : Text property accept text to be display in the control.
You can directly write the string or you
can retrieve the string from string.xml file.Here is the example
directly write
<EditText
android:id="@+id/txt_user_name"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:hint="Please
enter username"
android:imeActionId="6"
android:maxLines="1"
android:singleLine="true"
android:textColor="#000000"
android:textSize="30sp"
android:background="#FFFFFF"
android:gravity="center"
android:text="Hello World" />
text from string.Xml
<EditText
android:id="@+id/txt_user_name"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:hint="Please
enter username"
android:imeActionId="6"
android:maxLines="1"
android:singleLine="true"
android:textColor="#000000"
android:textSize="30sp"
android:background="#FFFFFF"
android:gravity="center"
android:text="@string/UserName" />
code
output
EditText has some variety of nature of accepting the text. It can accept a single line text. Here is the example
<EditText
android:id="@+id/txt_user_name"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:hint="Please
enter username"
android:imeActionId="6"
android:maxLines="1"
android:singleLine="true"
android:textColor="#000000"
android:textSize="30sp"
android:background="#FFFFFF"
android:gravity="center"
android:text="@string/UserName" />
EditText can accept multiple line of text, here is the example.
<EditText
android:id="@+id/txt_user_name"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:lines="8"
android:minLines="6"
android:imeActionId="6"
android:maxLines="5"
android:singleLine="false"
android:textColor="#000000"
android:textSize="20sp"
android:background="#FFFFFF"
android:gravity="center"
/>
EditText connection password. Input type password property accept password.Here is the example.
<EditText
android:id="@+id/txt_user_name"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:lines="1"
android:minLines="1"
android:imeActionId="6"
android:maxLines="1"
android:inputType="textPassword"
android:singleLine="true"
android:textColor="#000000"
android:textSize="20sp"
android:background="#FFFFFF"
android:gravity="center"
/>
You can design your EditText in variety of format. You can the font size, colour of font background ect. Here is the example.Here text size is 30sp and background color is #CA5100 and fore color is #CA5100.
<EditText
android:id="@+id/txt_user_name"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:minLines="1"
android:imeActionId="1"
android:maxLines="5"
android:singleLine="false"
android:textColor="#1C4475"
android:textSize="30sp"
android:background="#CA5100"
android:gravity="center"
/>
EditText event handling is a very easy process. Below section show that how and even handle can be done.
EditText
btn2 = FindViewById(Resource.Id.txt_user_name);
btn2.Click
+= (object
sender, EventArgs eventArgs) =>
{
/*
your statement */
};
No comments:
Post a Comment