Getting and Setting Values

Getting Values from EditText and displaying them by Setting the TextView.

    public void onBtnClick (View view){
        EditText etFirstName = findViewById(R.id.editTextFirstName);
        TextView tvFirstName = findViewById(R.id.textViewFirstName);
        tvFirstName.setText(etFirstName.getText().toString());

        EditText etLastName = findViewById(R.id.editTextLastName);
        TextView tvLastName = findViewById(R.id.textViewLastName);
        tvLastName.setText(etLastName.getText().toString());

        EditText etEmail = findViewById(R.id.editTextTextEmailAddress);
        TextView tvEmail = findViewById(R.id.textViewEmail);
        tvEmail.setText(etEmail.getText().toString());
    }

In xml file the important line is android:onClick="onBtnClick".

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/buttonToChangeText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="32dp"
        android:onClick="onBtnClick"
        android:text="Register"
        app:layout_constraintEnd_toEndOf="@+id/editTextTextEmailAddress"
        app:layout_constraintStart_toStartOf="@+id/editTextTextEmailAddress"
        app:layout_constraintTop_toBottomOf="@+id/editTextTextEmailAddress" />

    <EditText
        android:id="@+id/editTextFirstName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="100dp"
        android:ems="10"
        android:hint="First Name"
        android:inputType="textPersonName"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.497"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <EditText
        android:id="@+id/editTextLastName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="24dp"
        android:ems="10"
        android:hint="Last Name"
        android:inputType="textPersonName"
        app:layout_constraintEnd_toEndOf="@+id/editTextFirstName"
        app:layout_constraintStart_toStartOf="@+id/editTextFirstName"
        app:layout_constraintTop_toBottomOf="@+id/editTextFirstName" />

    <EditText
        android:id="@+id/editTextTextEmailAddress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="24dp"
        android:ems="10"
        android:hint="Email"
        android:inputType="textEmailAddress"
        app:layout_constraintEnd_toEndOf="@+id/editTextLastName"
        app:layout_constraintStart_toStartOf="@+id/editTextLastName"
        app:layout_constraintTop_toBottomOf="@+id/editTextLastName" />

    <TextView
        android:id="@+id/textViewFirstName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="176dp"
        android:layout_marginTop="100dp"
        android:layout_marginEnd="166dp"
        android:text="First Name"
        app:layout_constraintBottom_toTopOf="@+id/textViewLastName"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/buttonToChangeText"
        app:layout_constraintVertical_bias="0.779" />

    <TextView
        android:id="@+id/textViewLastName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="32dp"
        android:text="Last Name"
        app:layout_constraintEnd_toEndOf="@+id/textViewFirstName"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintStart_toStartOf="@+id/textViewFirstName"
        app:layout_constraintTop_toBottomOf="@+id/textViewFirstName" />

    <TextView
        android:id="@+id/textViewEmail"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="32dp"
        android:text="Email"
        app:layout_constraintEnd_toEndOf="@+id/textViewLastName"
        app:layout_constraintHorizontal_bias="0.303"
        app:layout_constraintStart_toStartOf="@+id/textViewLastName"
        app:layout_constraintTop_toBottomOf="@+id/textViewLastName" />

</androidx.constraintlayout.widget.ConstraintLayout>