Dept of CSE Designed By K.Dhanamjay
VEMU INSTITUTE OF TECHNOLOGY
Aim: Creating the Application by using Text Edit control
Theory:
EditText is a standard entry widget in android apps. It is an overlay over TextView that
configures itself to be editable. EditText is a subclass of TextView with text editing
operations. We often use EditText in our applications in order to provide an input or text
field, especially in forms.
Procedure:
Step1: Create a new project in Android Studio and name it EditTextExample.
Step2: Now open res -> layout -> xml (or) activity_main.xml and add following code. In this
code we have added multiple edittext and a button with onclick functionality.
Step3: Now open app -> java -> package -> MainActivity.java and add the below code.
In this we just fetch the text from the edittext, further with the button click event a toast will
show the text fetched before.
Source code:
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.edittextexample.MainActivity">
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/name"
android:inputType="textPersonName"
android:selectAllOnFocus="true" />
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/password_0_9"
android:inputType="numberPassword" />
<EditText
android:id="@+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/e_mail"
android:inputType="textEmailAddress" />
<EditText