Practice Project 1 [Android Studio] Registration Form APK

This is my first Android Studio Project. In this project, I'm going to make a simple Form Application. What this App exactly gonna do? Basically, in this app, We will gonna add a textbox, a simple text, and a button, whenever we write anything in the textbox and click on the button it will change the text.


Source Code

[main_activity.xml]


  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
<?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">
    <EditText
        android:id="@+id/firstname_txt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="60dp"
        android:ems="10"
        android:fontFamily="@font/carter_one"
        android:hint="First Name"
        android:inputType="textPersonName"
        android:textColor="#090909"
        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/lastname_txt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="52dp"
        android:ems="10"
        android:fontFamily="@font/carter_one"
        android:hint="Last Name"
        android:inputType="textPersonName"
        android:textColor="#000000"
        app:layout_constraintEnd_toEndOf="@+id/firstname_txt"
        app:layout_constraintStart_toStartOf="@+id/firstname_txt"
        app:layout_constraintTop_toBottomOf="@+id/firstname_txt" />

    <EditText
        android:id="@+id/email_txt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="52dp"
        android:ems="10"
        android:fontFamily="@font/carter_one"
        android:hint="Email"
        android:inputType="textPersonName"
        app:layout_constraintEnd_toEndOf="@+id/lastname_txt"
        app:layout_constraintStart_toStartOf="@+id/lastname_txt"
        app:layout_constraintTop_toBottomOf="@+id/lastname_txt" />

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="84dp"
        android:fontFamily="@font/carter_one"
        android:onClick="regbtn"
        android:text="Register Now"
        app:layout_constraintEnd_toEndOf="@+id/email_txt"
        app:layout_constraintStart_toStartOf="@+id/email_txt"
        app:layout_constraintTop_toBottomOf="@+id/email_txt" />

    <TextView
        android:id="@+id/txtfirstname"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="56dp"
        android:fontFamily="@font/carter_one"
        android:text="First Name:"
        android:textColor="#000000"
        android:textSize="14sp"
        app:layout_constraintEnd_toEndOf="@+id/button"
        app:layout_constraintStart_toStartOf="@+id/button"
        app:layout_constraintTop_toBottomOf="@+id/button" />

    <TextView
        android:id="@+id/txtlastname"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="40dp"
        android:fontFamily="@font/carter_one"
        android:text="Last Name:"
        android:textColor="#000000"
        android:textSize="14sp"
        app:layout_constraintEnd_toEndOf="@+id/txtfirstname"
        app:layout_constraintStart_toStartOf="@+id/txtfirstname"
        app:layout_constraintTop_toBottomOf="@+id/txtfirstname" />

    <TextView
        android:id="@+id/txtemail"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="42dp"
        android:fontFamily="@font/carter_one"
        android:text="Email:"
        android:textColor="#000000"
        android:textSize="14sp"
        app:layout_constraintEnd_toEndOf="@+id/txtlastname"
        app:layout_constraintStart_toStartOf="@+id/txtlastname"
        app:layout_constraintTop_toBottomOf="@+id/txtlastname" />
</androidx.constraintlayout.widget.ConstraintLayout>


[main_activity.java]


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.xDroidDev.formapk;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

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

    public void regbtn (View view){

        TextView txtfirstname = findViewById(R.id.txtfirstname);
        TextView txtlastname = findViewById(R.id.txtlastname);
        TextView txtemail = findViewById(R.id.txtemail);

        EditText fitstname_txt = findViewById(R.id.firstname_txt);
        EditText lasttname_txt = findViewById(R.id.lastname_txt);
        EditText email_txt = findViewById(R.id.email_txt);

        txtfirstname.setText("First Name: " + fitstname_txt.getText().toString());
        txtlastname.setText("Last Name: " + lasttname_txt.getText().toString());
        txtemail.setText("Email: " + email_txt.getText().toString());

    }

}


Sample Apk Download

Post a Comment

0 Comments