Practical No 5.
Practical No 5.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp"
android:gravity="center">
<TextView android:id="@+id/nameLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textSize="18sp"
android:paddingBottom="8dp"/>
<EditText android:id="@+id/nameInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"/>
<TextView android:id="@+id/ageLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Age"
android:textSize="18sp"
android:paddingTop="16dp"
android:paddingBottom="8dp"/>
<EditText android:id="@+id/ageInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:padding="10dp"/>
<TextView android:id="@+id/phoneLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mobile Number"
android:textSize="18sp"
android:paddingTop="16dp"
android:paddingBottom="8dp"/>
<EditText android:id="@+id/phoneInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:padding="10dp"/>
<Button android:id="@+id/submitButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
android:layout_marginTop="20dp"/>
</LinearLayout>
---------------------------------------------------------------------------------
main.java
package com.example.studentdata;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
OUTPUT
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
@SuppressLint("MissingInflatedId")
@Override
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
nameInput = findViewById(R.id.nameInput);
ageInput = findViewById(R.id.ageInput);
phoneInput = findViewById(R.id.phoneInput);
submitButton = findViewById(R.id.submitButton);
submitButton.setOnClickListener(new View.OnClickListener() {
@Override
Toast.makeText(MainActivity.this, "Name: " + name + "\nAge: " + age + "\nPhone: " + phone,
Toast.LENGTH_LONG).show();
} });}