Android Tutorial TextView

In this tutorial we are going know how to use android TextView with a simple TextView example.
We will create a simple app which helps us understand how to use Android TextView. In our app the user enters data in the EditText field and when the user clicks the button the entered data is displayed in the TextView.
In Android a TextView is used to show text to the user.

First of all we have to create a new project and in the .xml file create one EditText field, one Button widget and one TextView  widget by just dragging and dropping them in Android Studio.

Here is the .xml file code of our TextView example.
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="" 
 android:layout_alignParentStart="true" />
 android:layout_marginTop="52dp" />

 android:text="Large Text" 
 android:layout_alignParentStart="true" />
Java code of our TextView example
 public class MainActivity extends AppCompatActivity {

    @Override    protected void onCreate(Bundle savedInstanceState) {

    public void onButtonClick(View view){
        EditText eText = (EditText)findViewById(;
        String userText = eText.getText().toString();
        TextView displayEnteredText = (TextView)findViewById(;

A String variable userText is created and is assigned the value it gets from the
user.The getText()method is used to get the text in the EditText field and is 
converted into string through the toString() method.
setText()method is used to set the text on the TextView.
So this was a simplest example of Android TextView.