Practical No 07
Practical No 07
Practical No 07
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="25dp"
android:text="Login Page" />
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="UserName :" />
<EditText
android:id="@+id/user"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="abc@gmail.com" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<TextView
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Password :" />
<EditText
android:id="@+id/pass"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="1234"
android:inputType="textPassword"/>
</TableRow>
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="172dp"
android:text="Login" />
</TableLayout>
MainActivity.java
package com.example.pr7;
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;
b= findViewById(R.id.btn1);
user = findViewById(R.id.user);
pass = findViewById(R.id.pass);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(user.getText().toString().equals("vaibhav") &
pass.getText().toString().equals("1234"))
{
Toast.makeText( getApplicationContext(),"Login
Sucessful",Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText( getApplicationContext(),"Login
UnSucessful",Toast.LENGTH_SHORT).show();
}
}
});
}
}
Output: