0% found this document useful (0 votes)
74 views3 pages

Simple Login Functionality in Android

Uploaded by

Miran Jamadar
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)
74 views3 pages

Simple Login Functionality in Android

Uploaded by

Miran Jamadar
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

package [Link].

myapplication;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
EditText username,password;
Button btnlogin;
String correct_username = "admin";
String getCorrect_password= "admin";
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
username = findViewById([Link]);
password = findViewById([Link]);
btnlogin= findViewById([Link]);
[Link](new [Link]() {
@Override
public void onClick(View v) { if([Link]([Link]().toString())||
[Link]([Link]().toString())){
[Link]([Link],"Empty data provided",Toast.LENGTH_LONG).show();
} else if ([Link]().toString().equals(correct_username)) {
if([Link]().toString().equals(getCorrect_password)){
[Link]([Link],"Sucessfully login",Toast.LENGTH_LONG).show();
}else{
[Link]([Link],"Invalid
username/password",Toast.LENGTH_LONG).show();
}
}else{
[Link]([Link],"Invalid
username/password",Toast.LENGTH_LONG).show();
} } }); }}

<?xml version="1.0" encoding="utf-8"?>


<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<EditText
android:id="@+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:textSize="30dp"
android:hint="Password"
android:inputType="textPassword"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.308"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.405" />

<EditText
android:id="@+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Username"
android:inputType="text"
android:text="Username"
android:textSize="30dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.308"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.29" />

<Button
android:id="@+id/btnlogin"
android:layout_width="121dp"
android:layout_height="81dp"
android:text="LOGIN"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.462"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.621" />

</[Link]>

You might also like