0% found this document useful (0 votes)
4 views4 pages

Exp 10

The document contains XML and Java code for an Android application featuring two login interfaces: one for social network login and another for student login. Each interface includes input fields for email and password, as well as buttons for login and additional actions like registration and password recovery. The Java code handles user authentication by checking predefined credentials and displaying appropriate success or error messages via Toast notifications.
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)
4 views4 pages

Exp 10

The document contains XML and Java code for an Android application featuring two login interfaces: one for social network login and another for student login. Each interface includes input fields for email and password, as well as buttons for login and additional actions like registration and password recovery. The Java code handles user authentication by checking predefined credentials and displaying appropriate success or error messages via Toast notifications.
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/ 4

1.

android:textColor="#D32F2F"
XML code: android:layout_marginTop="20dp"/>
<?xml version="1.0" encoding="utf-8"?> </LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/a Java code:
pk/res/android" package com.example.exp10;
android:layout_width="match_parent"
android:layout_height="match_parent" import android.content.Intent;
android:orientation="vertical" import android.os.Bundle;
android:padding="16dp" import android.view.View;
android:gravity="center" import android.widget.Button;
android:background="#E3F2FD"> import android.widget.EditText;
<TextView import android.widget.Toast;
android:layout_width="wrap_content" import
android:layout_height="wrap_content" androidx.appcompat.app.AppCompatActivity;
android:text="Social Network Login"
android:textSize="24sp" public class MainActivity extends
android:textStyle="bold" AppCompatActivity {
android:gravity="center" EditText email, password;
android:textColor="#1E88E5" Button loginButton;
android:layout_marginBottom="20dp"/>
<EditText @Override
android:id="@+id/email" protected void onCreate(Bundle
android:layout_width="match_parent" savedInstanceState) {
android:layout_height="wrap_content" super.onCreate(savedInstanceState);
android:hint="Enter Email" setContentView(R.layout.activity_main);
android:inputType="textEmailAddress"/>
<EditText email = findViewById(R.id.email);
android:id="@+id/password" password =
android:layout_width="match_parent" findViewById(R.id.password);
android:layout_height="wrap_content" loginButton =
android:hint="Enter Password" findViewById(R.id.loginButton);
android:inputType="textPassword"/>
<Button loginButton.setOnClickListener(new
android:id="@+id/loginButton" View.OnClickListener() {
android:layout_width="match_parent" @Override
android:layout_height="wrap_content" public void onClick(View v) {
android:text="Login" String userEmail =
android:backgroundTint="#1565C0" email.getText().toString();
android:textColor="@android:color/white" String userPassword =
android:layout_marginTop="16dp"/> password.getText().toString();
<TextView
android:layout_width="wrap_content" if
android:layout_height="wrap_content" (userEmail.equals("[email protected]")
android:text="Performed by Khushi && userPassword.equals("12345")) {
Satam 39"
android:textSize="14sp" Toast.makeText(MainActivity.this, "Login
android:textStyle="bold" Successful",
android:gravity="center" Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MainActivity.this, "Invalid 2.
Email or Password", XML code:
Toast.LENGTH_SHORT).show(); <?xml version="1.0" encoding="utf-8"?>
} <LinearLayout
} xmlns:android="http://schemas.android.com/a
}); pk/res/android"
} android:layout_width="match_parent"
} android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp"
android:gravity="center"
android:background="@android:color/white">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Student Login"
android:textSize="24sp"
android:textStyle="bold"
android:gravity="center"
android:textColor="@android:color/black"
android:layout_marginBottom="20dp"/>
<EditText
android:id="@+id/studentEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Student Email"
android:inputType="textEmailAddress"
android:textColor="@android:color/black"
android:textColorHint="@android:color/darker
_gray"/>
<EditText
android:id="@+id/studentPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Password"
android:inputType="textPassword"
android:textColor="@android:color/black"
android:textColorHint="@android:color/darker
_gray"/>
<Button
android:id="@+id/studentLoginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login"
android:backgroundTint="@android:color/hol
o_blue_dark"
android:textColor="@android:color/white"
android:layout_marginTop="16dp"/>
<TextView
android:id="@+id/registerText"
setContentView(R.layout.activity_main);
android:layout_width="wrap_content" studentEmail =
android:layout_height="wrap_content" findViewById(R.id.studentEmail);
android:text="New User? Register Here" studentPassword =
android:textColor="@android:color/holo_blue findViewById(R.id.studentPassword);
_dark" studentLoginButton =
android:layout_marginTop="10dp" findViewById(R.id.studentLoginButton);
android:textStyle="bold" registerText =
android:clickable="true"/> findViewById(R.id.registerText);
<TextView forgotPasswordText =
android:id="@+id/forgotPasswordText" findViewById(R.id.forgotPasswordText);
android:layout_width="wrap_content" studentLoginButton.setOnClickListener(new
android:layout_height="wrap_content" View.OnClickListener() {
android:text="Forgot Password?" @Override
android:textColor="@android:color/holo_red_ public void onClick(View v) {
dark" String email =
android:layout_marginTop="5dp" studentEmail.getText().toString();
android:textStyle="bold" String password =
android:clickable="true"/> studentPassword.getText().toString();
<TextView if
android:layout_width="wrap_content" (email.equals("[email protected]") &&
android:layout_height="wrap_content" password.equals("password123")) {
android:text="Performed by Akshay
Parab” Toast.makeText(MainActivity.this, "Login
android:textColor="@android:color/black" Successful",
android:layout_marginTop="10dp" Toast.LENGTH_SHORT).show();
android:textStyle="bold" } else {
android:clickable="true"/>
</LinearLayout> Toast.makeText(MainActivity.this, "Invalid
Credentials",
Java code: Toast.LENGTH_SHORT).show();
package com.example.exp10; }
import android.content.Intent; }
import android.os.Bundle; });
import android.view.View; registerText.setOnClickListener(new
import android.widget.Button; View.OnClickListener() {
import android.widget.EditText; @Override
import android.widget.TextView; public void onClick(View v) {
import android.widget.Toast; }
import });
androidx.appcompat.app.AppCompatActivity; forgotPasswordText.setOnClickListener(new
public class MainActivity extends View.OnClickListener() {
AppCompatActivity { @Override
EditText studentEmail, studentPassword; public void onClick(View v) {
Button studentLoginButton; Toast.makeText(MainActivity.this,
TextView registerText, "Reset password option coming soon!",
forgotPasswordText; Toast.LENGTH_SHORT).show();
@Override }
protected void onCreate(Bundle });
savedInstanceState) { }
super.onCreate(savedInstanceState); }

You might also like