0% found this document useful (0 votes)
43 views2 pages

Practical 27

The document describes an Android login form layout with fields for username and password. It includes the XML layout code and Java code to handle form submission and validation.

Uploaded by

Ritesh Kolate
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)
43 views2 pages

Practical 27

The document describes an Android login form layout with fields for username and password. It includes the XML layout code and Java code to handle form submission and validation.

Uploaded by

Ritesh Kolate
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/ 2

Practical 25

activity_main.xml android:layout_y="78dp"
<?xml version="1.0" encoding="utf-8"?> android:ems="10"
<AbsoluteLayout android:inputType="text"
xmlns:android="http://schemas.android.com/apk/res/android" android:hint="Name" />
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" <EditText
android:layout_width="match_parent" android:id="@+id/e2"
android:layout_height="match_parent" android:layout_width="wrap_content"
android:background="@drawable/pr27" android:layout_height="wrap_content"
tools:context=".MainActivity"> android:layout_x="142dp"
android:layout_y="129dp"
<TextView android:ems="10"
android:layout_width="398dp" android:inputType="text"
android:layout_height="wrap_content" android:hint="Password" />
android:layout_x="7dp"
android:layout_y="5dp" <Button
android:background="@color/black" android:id="@+id/b1"
android:padding="10dp" android:textSize="20dp"
android:text="Login Form" android:layout_width="wrap_content"
android:textAlignment="center" android:layout_height="wrap_content"
android:textColor="@color/white" android:layout_x="142dp"
android:textSize="20dp" android:layout_y="202dp"

/> android:text="Login" />

<TextView </AbsoluteLayout>
android:id="@+id/t1"
android:layout_width="wrap_content" MainActvity.java
android:layout_height="wrap_content"
android:layout_x="34dp"
android:layout_y="87dp"
android:text="Username:"
android:textStyle="bold"
android:textSize="20dp" />

<TextView
android:id="@+id/t2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="35dp"
android:layout_y="137dp"
android:text="Password:"
android:textStyle="bold"
android:textSize="20dp" />

<EditText
android:id="@+id/e1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="138dp"
MainActvity.java Output:

package com.example.practical27;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import java.util.Objects;

public class MainActivity extends AppCompatActivity {


EditText e1,e2;
Button b1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
e1=findViewById(R.id.e1);
e2=findViewById(R.id.e2);
b1=findViewById(R.id.b1);
b1.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {

if(Objects.equals(e1.getText().toString(),"rsk")&&Objects.
equals(e2.getText().toString(),"1234"))
{
Toast.makeText(MainActivity.this, "Login
Successfully", Toast.LENGTH_LONG).show();
}
else {
Toast.makeText(MainActivity.this,"Invalide
Credentials",Toast.LENGTH_LONG).show();
}
}
});
}
}

You might also like