0% found this document useful (0 votes)
12 views8 pages

Practical 7

The document contains code for two Android applications, Practical 7.1 and Practical 7.2, each with its own AndroidManifest.xml, layout (activity_main.xml), and MainActivity.java files. Practical 7.1 features a login form that checks for specific credentials, while Practical 7.2 collects student information and displays a submission message. Both applications utilize similar structures and components, including EditText fields and buttons.

Uploaded by

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

Practical 7

The document contains code for two Android applications, Practical 7.1 and Practical 7.2, each with its own AndroidManifest.xml, layout (activity_main.xml), and MainActivity.java files. Practical 7.1 features a login form that checks for specific credentials, while Practical 7.2 collects student information and displays a submission message. Both applications utilize similar structures and components, including EditText fields and buttons.

Uploaded by

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

Practical 7.

1
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Pr7_1"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />


</intent-filter>
</activity>
</application>
</manifest>
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="LOGIN FORM:"
android:textColor="#f0f"
android:textSize="20dp"
android:padding="10dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter User Name:"
android:id="@+id/edt1"
android:padding="10dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Password:"
android:id="@+id/edt2"
android:padding="10dp"/>
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="LOGIN"
android:textColor="#0f0"
android:layout_marginTop="10dp"
android:padding="10dp"/>
</LinearLayout>

MainActivity.java
package com.example.pr7_1;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText e1=(EditText) findViewById(R.id.edt1);
EditText e2=(EditText) findViewById(R.id.edt2);
Button b1=(Button) findViewById(R.id.btn1);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String s1=e1.getText().toString();
String s2=e2.getText().toString();
if(s1.equals("DYP")&&s2.equals("ANYA"))
{
Toast.makeText(MainActivity.this, "LOGIN SUCCESSFULLTY",
Toast.LENGTH_SHORT).show();
}
else {
Toast.makeText(MainActivity.this, "LOGIN UNSUCCESSFULLY",
Toast.LENGTH_SHORT).show();
}
}
});
}
}
OUTPUT:
Practical 7.2
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Pr7_2"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />


</intent-filter>
</activity>
</application>
</manifest>
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:layout_margin="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="STUDENT INFORMTION:"
android:textSize="20dp"
android:textColor="#f0f"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="ENTER NAME:"
android:id="@+id/edt1"
android:padding="15dp"
android:textColorHint="#0f0"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="ENTER ROLLNO:"
android:padding="15dp"
android:id="@+id/edt2"
android:textColorHint="#0f0"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="ENTER EMAIL:"
android:padding="15dp"
android:id="@+id/edt3"
android:textColorHint="#0f0"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="ENTER ADDRESS:"
android:padding="15dp"
android:id="@+id/edt4"
android:textColorHint="#0f0"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SUBMIT"
android:textColor="#f0f"
android:layout_gravity="center"
android:id="@+id/btn1"
/>
</LinearLayout>
MainActivity.java
package com.example.pr7_2;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText e1=(EditText) findViewById(R.id.edt1);
EditText e2=(EditText) findViewById(R.id.edt2);
EditText e3=(EditText) findViewById(R.id.edt3);
EditText e4=(EditText) findViewById(R.id.edt4);
Button b1=(Button) findViewById(R.id.btn1);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "DATA IS
SUBMITTED", Toast.LENGTH_SHORT).show();
}
});
}
}
OUTPUT:

You might also like