0% found this document useful (0 votes)
670 views

3) Write A Program To Accept and Display Personal Information of The Student.

The document describes a program that accepts and displays personal information of a student. It includes an XML layout file that defines EditText fields for name, age, and department and Button and TextView widgets. It also includes a Java code file that handles input from the EditText fields and displays the input in the TextView widgets.

Uploaded by

ethicalninja7
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
670 views

3) Write A Program To Accept and Display Personal Information of The Student.

The document describes a program that accepts and displays personal information of a student. It includes an XML layout file that defines EditText fields for name, age, and department and Button and TextView widgets. It also includes a Java code file that handles input from the EditText fields and displays the input in the TextView widgets.

Uploaded by

ethicalninja7
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

3) Write a program to accept and display personal information of the student.

Exp-7 Ans:activitymain.xml

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout
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"
tools:context=".MainActivity"
android:orientation="vertical">

<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="name" />

<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName" />

<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="age" />

<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number" />

<TextView
android:id="@+id/textView3"
layout_width="match_parent"
android:layout_height="wrap_content"
android:text="department" />

<EditText
android:id="@+id/editText3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName" />

<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="submit"
android:onClick="submit" />

<TextView
android:id="@+id/textView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />

<TextView
android:id="@+id/textView5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />

<TextView
android:id="@+id/textView6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />

</LinearLayout>

___________________________________________________________________________________
_______________________________________________________________________

* Mainactivity.java

package com.example.username;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity
{
private EditText t1;
private EditText t2;
private EditText t3;
private TextView o1;
private TextView o2;
private TextView o3;

@Override protected void onCreate(Bundle savedInstanceState)


{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
t1=findViewById(R.id.editText1);
t2=findViewById(R.id.editText2);
t3=findViewById(R.id.editText3);
o1=findViewById(R.id.textView4);
o2=findViewById(R.id.textView5);
o3=findViewById(R.id.textView6);
}
public void submit(View view)
{
String name=t1.getText().toString();
String age=t2.getText().toString();
String dept=t3.getText().toString();
o1.setText(name);
o2.setText(age);
o3.setText(dept);
}
}

You might also like