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

Create simple login page in Android Studio

1- Open the Android studio software.

2- Open a new project, (File New New Project)

3- Select the EmptyActivity.

4- Set the project name , location, and select Kotlin language.

5- From palette panel, add a button, Password and Email.

6- Set the hint of the Email to username, and assign an ID for it.

7- Set the hint of the password to pass and assign an ID for it.

8- Set the button name to Login and assign an ID for it.

9- In the main activity, write a code to check the entered text to the username and password,

if it matches then shows a massage to the status as “Logged in successfully ”, otherwise

“Login fail”.

Hint Code
buttonlg.setOnClickListener {
var status= if (usernamee.text.toString().equals("mobina.beheshti") &&
pass.text.toString().equals("123mb"))
"Logged In Successfully" else "LogIn Fail"
Toast.makeText( this , status, Toast.LENGTH_SHORT).show()
}

An Android Toast is a small message displayed on the screen, similar to a tool tip or other
similar popup notification. A Toast is displayed on the main content of an activity, and only
remains visible for a short time period.

You might also like