0% found this document useful (0 votes)
8 views5 pages

Practical No. 07 - 1

The document contains an Android application code that accepts a username and password from the user through a graphical user interface. It includes XML layout files for the user interface and Java code for the main activity that handles user input and displays a success message. Additionally, it features a section to collect and display student information such as name, age, and mobile number.

Uploaded by

ganeshkumbhar638
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views5 pages

Practical No. 07 - 1

The document contains an Android application code that accepts a username and password from the user through a graphical user interface. It includes XML layout files for the user interface and Java code for the main activity that handles user input and displays a success message. Additionally, it features a section to collect and display student information such as name, age, and mobile number.

Uploaded by

ganeshkumbhar638
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Q.

Write a program to accept username and <LinearLayout


password from the end user using Text View android:layout_width="match_parent"
and Edit Text. android:layout_height="wrap_content"
activity_main.xml android:gravity="center"
android:layout_marginTop="10dp">
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout <Button
xmlns:android="http://schemas.android.com/apk/r android:id="@+id/btn"
es/android" android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res- android:text="Submit"
auto" android:onClick="setdata"/>

xmlns:tools="http://schemas.android.com/tools" </LinearLayout>
android:id="@+id/main"
android:layout_width="match_parent" <TextView
android:layout_height="match_parent" android:id="@+id/text1"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_margin="20dp" android:layout_height="wrap_content"
android:gravity="center" android:layout_marginTop="30dp"
tools:context=".MainActivity"> android:textSize="20dp"
android:gravity="center"
<TextView android:text=""/>
android:layout_width="match_parent"
android:layout_height="wrap_content" </LinearLayout>
android:text="Username : "
android:textSize="20dp"/> MainActivity.java
<EditText
android:layout_width="match_parent" package com.example.practicalno7_1;
android:layout_height="wrap_content"
android:hint="Enter username" import
android:inputType="text"/> androidx.appcompat.app.AppCompatActivity;
<TextView
android:layout_width="match_parent" import android.os.Bundle;
android:layout_height="wrap_content" import android.view.View;
android:text="password : " import android.widget.Button;
android:textSize="20dp"/> import android.widget.TextView;
<EditText
android:layout_width="match_parent" public class MainActivity extends
android:layout_height="wrap_content" AppCompatActivity {
android:hint="Enter username" TextView tnm;
android:inputType="textPassword"/> Button btn;
@Override Q. Write a program to accept and display
protected void onCreate(Bundle personal information of the student.
savedInstanceState) {
super.onCreate(savedInstanceState); activity_main.xml
setContentView(R.layout.activity_main); <?xml version="1.0" encoding="utf-8"?>
<LinearLayout
tnm=(TextView)findViewById(R.id.text1); xmlns:android="http://schemas.android.com/apk/res
btn=(Button) findViewById(R.id.btn); /android"
} xmlns:app="http://schemas.android.com/apk/res-
public void setdata(View view) auto"
{ xmlns:tools="http://schemas.android.com/tools"
tnm.setText("Login Successfully"); android:layout_width="match_parent"
} android:layout_height="match_parent"
} tools:context=".MainActivity"
android:layout_margin="5dp"
android:orientation="vertical">

<TextView
android:id="@+id/txtlebl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="STUDENT INFORMATION"
android:gravity="center"
android:textSize="30sp"
android:layout_marginTop="5sp"
android:padding="10dp"
android:background="#952FA6"
android:textColor="#FFFFFF"
/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp">

<TextView android:id="@+id/tnm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Student Name :"
android:textSize="25dp"
android:layout_marginTop="10sp"
android:padding="10dp"
android:textColor="#1B0202" android:layout_height="wrap_content">
/> <TextView
<EditText android:id="@+id/txtmobno"
android:id="@+id/edtname" android:layout_width="wrap_content"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:text="Mobile No :"
android:padding="10dp" android:textSize="25sp"
android:ems="10" android:layout_marginTop="10sp"
android:inputType="text" android:padding="10dp"
android:text="" android:textColor="#050000"
android:layout_marginTop="15dp" />

/> <EditText
</LinearLayout> android:id="@+id/edtmob"
<LinearLayout android:layout_width="match_parent"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:padding="10dp"
android:orientation="horizontal"> android:inputType="text"
<TextView android:text=""
android:id="@+id/txtage" android:ems="10"
android:layout_width="wrap_content" android:layout_marginTop="15dp"
android:layout_height="wrap_content"
android:text="Age :"
android:textSize="25sp" />
android:layout_marginTop="10sp" </LinearLayout>
android:padding="10dp"
android:textColor="#050000" <Button
/> android:id="@+id/button"
<EditText android:layout_width="wrap_content"
android:id="@+id/edtage" android:layout_height="wrap_content"
android:layout_width="match_parent" android:onClick="setdata"
android:layout_height="wrap_content" android:text=" SUBMIT "
android:padding="10dp" android:layout_gravity="center"
android:inputType="text" android:layout_marginTop="30dp"
android:text="" android:textSize="25dp"
android:ems="10" android:padding="10dp"
android:layout_marginTop="15dp" />
<TextView
/> android:id="@+id/txtstud"
android:layout_width="match_parent"
</LinearLayout> android:layout_height="wrap_content"
<LinearLayout android:text=""
android:layout_width="match_parent" android:textSize="25sp"
android:layout_marginTop="20sp" TextView tnm, tage, tmob;
android:padding="10dp" EditText enm, eage, emob;
android:textColor="#050000" Button btn;
/>
<TextView @Override
android:id="@+id/txtstudage" protected void onCreate(Bundle
android:layout_width="match_parent" savedInstanceState) {
android:layout_height="wrap_content" super.onCreate(savedInstanceState);
android:text="" setContentView(R.layout.activity_main);
android:textSize="25sp" enm=(EditText)
android:layout_marginTop="10sp" findViewById(R.id.edtname);
android:padding="10dp" eage=(EditText) findViewById(R.id.edtage);
android:textColor="#050000" emob=(EditText)
/> findViewById(R.id.edtmob);
`<TextView
android:id="@+id/txtmob" tnm=(TextView)findViewById(R.id.txtstud);
android:layout_width="match_parent"
android:layout_height="wrap_content" tage=(TextView)findViewById(R.id.txtstudage);
android:text=" "
android:textSize="25sp" tmob=(TextView)findViewById(R.id.txtmob);
android:layout_marginTop="10sp" btn=(Button) findViewById(R.id.button);
android:padding="10dp" }
android:textColor="#050000" public void setdata(View view)
/> {
</LinearLayout> tnm.setText("Name :"
+enm.getText().toString());
MainActivity.java tage.setText("Age
:"+eage.getText().toString());
package com.example.practicalno7_1; tmob.setText("Mobile No
:"+emob.getText().toString());
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;

import com.example.practicalno7_1.R;

public class MainActivity extends


AppCompatActivity {

You might also like