Android EditText View Simple Example Tutorial

How to get text from user into android app.

EditText view tag is used to obtain text from user into android application. EditText tag is one of the most useful tag to get text from application user. So here is the complete step by step tutorial for Android EditText View Simple Example Tutorial.

Android EditText View Simple Example Tutorial.

Code for EditText View tag :

<EditText
android:id=”@+id/editText1″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:inputType=”text” >

Android EditText View Simple Example Tutorial

Complete source code for MainActvity.java file.

package com.android_examples.com.edittext;

import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

Complete source code for activity_main.xml file.

<RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android”
xmlns:tools=”http://schemas.android.com/tools”
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:paddingBottom=”@dimen/activity_vertical_margin”
android:paddingLeft=”@dimen/activity_horizontal_margin”
android:paddingRight=”@dimen/activity_horizontal_margin”
android:paddingTop=”@dimen/activity_vertical_margin”
tools:context=”com.android_examples.com.edittext.MainActivity” >

<EditText
android:id=”@+id/editText1″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_alignParentTop=”true”
android:layout_centerHorizontal=”true”
android:layout_marginTop=”103dp”
android:ems=”10″
android:inputType=”text” >

<requestFocus />
</EditText>

</RelativeLayout>

 

Leave a Reply

Your email address will not be published. Required fields are marked *