Mad Practical 10

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

app:layout_constraintTop_toTopOf="parent"

Mad Practical 10 app:layout_constraintVertical_bias="0.817" />

XML Code :- <ImageButton


android:id="@+id/imageButton"
<?xml version="1.0" encoding="utf-8"?> android:layout_width="143dp"
<androidx.constraintlayout.widget.ConstraintLayout android:layout_height="171dp"
xmlns:android="http://schemas.android.com/apk/res/andro
id" app:layout_constraintBottom_toTopOf="@+id/textView"
xmlns:app="http://schemas.android.com/apk/res-auto" app:layout_constraintEnd_toEndOf="parent"
xmlns:tools="http://schemas.android.com/tools" app:layout_constraintStart_toStartOf="parent"
android:layout_width="match_parent" app:layout_constraintTop_toTopOf="parent"
android:layout_height="match_parent" app:layout_constraintVertical_bias="0.373"
tools:context=".MainActivity"> app:srcCompat="@drawable/pr_10"
tools:ignore="SpeakableTextPresentCheck" />
<TextView </androidx.constraintlayout.widget.ConstraintLayout>
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="36dp" Java Code :-
android:fontFamily="sans-serif"
android:text="LOGIN" package com.example.mad_practical_10;
android:textColor="#3044B1"
android:textSize="30sp" import androidx.appcompat.app.AppCompatActivity;
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/edt1" import android.os.Bundle;
app:layout_constraintEnd_toEndOf="parent" import android.view.View;
app:layout_constraintStart_toStartOf="parent" import android.widget.Button;
/> import android.widget.EditText;
import android.widget.Toast;
<EditText
android:id="@+id/edt1" public class MainActivity extends AppCompatActivity {
android:layout_width="0dp" EditText ed1, ed2;
android:layout_height="wrap_content" Button b1;
android:layout_margin="40dp"
android:layout_marginBottom="192dp" @Override
android:background="@drawable/round_shape" protected void onCreate(Bundle savedInstanceState)
android:ems="10" {
android:hint="E-mail address" super.onCreate(savedInstanceState);
android:inputType="textEmailAddress" setContentView(R.layout.activity_main);
android:padding="15dp"
android:textColorHint="#3044B1" ed1 = findViewById(R.id.edt1);
android:textSize="18sp" ed2 = findViewById(R.id.edt2);
app:layout_constraintBottom_toTopOf="@+id/edt2" b1 = findViewById(R.id.button);
app:layout_constraintEnd_toEndOf="parent" b1.setOnClickListener(new
app:layout_constraintStart_toStartOf="parent" View.OnClickListener() {
/> @Override
public void onClick(View v) {
<EditText if
android:id="@+id/edt2" (String.valueOf(ed1.getText()).equals("") &&
android:layout_width="0dp" String.valueOf(ed2.getText()).equals("")){
android:layout_height="wrap_content" Toast.makeText(MainActivity.this,
android:layout_margin="40dp" "Please enter e-mail & password",
android:layout_marginBottom="212dp" Toast.LENGTH_SHORT).show();
android:background="@drawable/round_shape" } else if
android:ems="10" (String.valueOf(ed1.getText()).equals("[email protected]"
android:hint="Password" ) && String.valueOf(ed2.getText()).equals("Admin123")){
android:inputType="textPassword" Toast.makeText(MainActivity.this,
android:padding="15dp" "Login Successfully", Toast.LENGTH_SHORT).show();
android:textColorHint="#3044B1" } else {
android:textSize="18sp" Toast.makeText(MainActivity.this,
"Incorrect e-mail & password",
app:layout_constraintBottom_toTopOf="@+id/button" Toast.LENGTH_SHORT).show();
app:layout_constraintEnd_toEndOf="parent" }
app:layout_constraintHorizontal_bias="0.562" }
app:layout_constraintStart_toStartOf="parent" });
/>
}
<Button }
android:id="@+id/button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="45dp"
android:backgroundTint="#FF5141"
android:paddingTop="15dp"
android:paddingBottom="15dp"
android:text="Login"
android:textSize="20sp"
android:textStyle="bold"
app:cornerRadius="35dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.55"
app:layout_constraintStart_toStartOf="parent"
Output :-
MAD Practical 10_1 app:layout_constraintHorizontal_bias="0.5
"
XML Code:-
app:layout_constraintStart_toStartOf="par
<?xml version="1.0" encoding="utf-8"?> ent"
<androidx.constraintlayout.widget.Constra
intLayout app:layout_constraintTop_toBottomOf="@+id
xmlns:android="http://schemas.android.com /textView2" />
/apk/res/android"
<EditText
xmlns:app="http://schemas.android.com/apk android:id="@+id/edt2"
/res-auto" android:layout_width="0dp"

xmlns:tools="http://schemas.android.com/t android:layout_height="wrap_content"
ools" android:layout_margin="40dp"
android:layout_width="match_parent" android:layout_marginTop="184dp"
android:layout_height="match_parent"
android:background="#3F50AE" android:background="@drawable/edt_shape"
tools:context=".MainActivity"> android:ems="10"
android:hint="Enter your address"
<TextView
android:id="@+id/textView2" android:inputType="textPersonName"
android:padding="10dp"
android:layout_width="wrap_content" android:textColor="#070707"
android:textColorHint="#070707"
android:layout_height="wrap_content"
android:text="Register Here" app:layout_constraintEnd_toEndOf="parent"
android:textColor="#FFFFFF"
android:textSize="20sp" app:layout_constraintStart_toStartOf="par
android:textStyle="bold" ent"

app:layout_constraintBottom_toBottomOf="p app:layout_constraintTop_toBottomOf="@+id
arent" /edt4" />

app:layout_constraintLeft_toLeftOf="paren <RadioGroup
t" android:id="@+id/radioGroup"
android:layout_width="0dp"
app:layout_constraintRight_toRightOf="par
ent" android:layout_height="wrap_content"
android:layout_margin="40dp"
app:layout_constraintTop_toTopOf="parent" android:orientation="horizontal"
android:paddingTop="10dp"
app:layout_constraintVertical_bias="0.059 android:paddingBottom="10dp"
" /> app:flow_horizontalAlign="center"
app:flow_verticalAlign="center"
<EditText
android:id="@+id/edt1" app:layout_constraintEnd_toEndOf="parent"
android:layout_width="0dp"
app:layout_constraintStart_toStartOf="par
android:layout_height="wrap_content" ent"
android:layout_margin="40dp"
app:layout_constraintTop_toBottomOf="@+id
android:background="@drawable/edt_shape" /edt2">
android:ems="10"
android:hint="Enter your name" <RadioButton
android:id="@+id/rb1"
android:inputType="textPersonName" android:layout_width="100dp"
android:padding="10dp"
android:textColor="#070707" android:layout_height="wrap_content"
android:textColorHint="#070707"
android:background="@drawable/edt_shape"
app:layout_constraintEnd_toEndOf="parent" android:padding="10dp"
android:text="Male"
android:textColor="#0B0A0A"
android:textSize="18sp" /> app:layout_constraintTop_toBottomOf="@+id
/edt1" />
<RadioButton
android:id="@+id/rb2" <Button
android:layout_width="120dp" android:id="@+id/button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="60dp" android:layout_margin="55dp"
android:layout_marginTop="460dp"
android:background="@drawable/edt_shape" android:backgroundTint="#E91E63"
android:padding="10dp" android:padding="10dp"
android:text="Female" android:text="Register"
android:textColor="#000000" android:textSize="16sp"
android:textSize="18sp" /> android:textStyle="bold"
</RadioGroup>
app:layout_constraintEnd_toEndOf="parent"
<EditText
android:id="@+id/edt3" app:layout_constraintHorizontal_bias="0.4
android:layout_width="0dp" 95"

android:layout_height="wrap_content" app:layout_constraintStart_toStartOf="par
android:layout_margin="40dp" ent"

android:background="@drawable/edt_shape" app:layout_constraintTop_toBottomOf="@+id
android:ems="10" /edt3" />
android:hint="Enter your birth
date"
android:inputType="date" </androidx.constraintlayout.widget.Constr
android:padding="10dp" aintLayout>
android:textColor="#020202"
android:textColorHint="#050505"
Java Code:-
app:layout_constraintEnd_toEndOf="parent"
package com.example.mad_practical_10_1;
app:layout_constraintStart_toStartOf="par
ent" import
androidx.appcompat.app.AppCompatActivity;
app:layout_constraintTop_toBottomOf="@+id
import android.os.Bundle;
/radioGroup" /> import android.view.View;
import android.widget.ArrayAdapter;
<EditText import android.widget.Button;
android:id="@+id/edt4" import android.widget.EditText;
android:layout_width="0dp" import android.widget.RadioButton;
import android.widget.Spinner;
android:layout_height="wrap_content" import android.widget.Toast;
android:layout_margin="40dp"
android:layout_marginTop="24dp" public class MainActivity extends
AppCompatActivity {
Button b1;
android:background="@drawable/edt_shape" EditText ed1,ed2;
android:ems="10" String s1,s2;
android:hint="Enter your phone
number" @Override
android:inputType="number" protected void onCreate(Bundle
android:padding="10dp" savedInstanceState) {
android:textColor="#090909" super.onCreate(savedInstanceState);
android:textColorHint="#090909"
setContentView(R.layout.activity_main);
app:layout_constraintEnd_toEndOf="parent" b1 = findViewById(R.id.button);
ed1 = findViewById(R.id.edt1);
app:layout_constraintStart_toStartOf="par ed2 = findViewById(R.id.edt2);
ent"
b1.setOnClickListener(new
View.OnClickListener() {
@Override
public void onClick(View v) {
s1 =
String.valueOf(ed1.getText());
s2 =
String.valueOf(ed2.getText());

if (s1.equals("") ||
s2.equals("")){

Toast.makeText(MainActivity.this, "Please
enter your information",
Toast.LENGTH_SHORT).show();
} else {

Toast.makeText(MainActivity.this, "Register
Successfully", Toast.LENGTH_SHORT).show();
}

}
});
}
}

Output:-

You might also like