Login and registration form Click on listener in android studio code

Step1: Start with Creating a new Project>File>New>New Project

Login and registration form in android studio code-Programmer Knows

Step2:  After creating the project

Below is the activity

First Activity:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <include
        android:id="@+id/toolbar"
        layout="@layout/activity_toolbar"
        >

    </include>
    <TextView
        android:id="@+id/Wamu"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="WAMU!"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="20dp"
        android:textColor="#000"
        android:textSize="40dp"
        android:textStyle="bold"
        android:layout_below="@id/toolbar"
        >

    </TextView>
    <EditText
        android:id="@+id/ph1"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:hint=" Phone Number or Email"
        android:drawableLeft="@drawable/email_sign"
        android:textSize="20dp"
        android:background="#fff"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginTop="10dp"
        android:layout_below="@id/Wamu"
        android:textColor="#000"

        />

    <EditText
        android:id="@+id/Pa2"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:hint=" Password"
        android:inputType="textPassword"
        android:drawableLeft="@drawable/lock_open"
        android:background="#fff"
        android:layout_below="@id/ph1"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginTop="10dp"
        android:textColor="#000"
        android:textSize="20dp"

        >
</EditText>

    <Button
        android:id="@+id/login"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#6A95CC"
        android:layout_marginLeft="40dp"
        android:layout_centerInParent="true"
        android:layout_marginTop="40dp"
        android:layout_below="@id/Pa2"
        android:text="Login"
        android:textSize="20dp"
        android:textColor="#fff"
>
</Button>
    <TextView
        android:id="@+id/or"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="OR"
        android:layout_centerInParent="true"
        android:layout_below="@id/login"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:textSize="30dp"
        android:textColor="#000"
         />
    <Button
        android:id="@+id/caa"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#6A95CC"
        android:layout_marginLeft="40dp"
        android:layout_centerInParent="true"
        android:text="Create an account"
        android:layout_below="@id/or"
        android:textSize="20dp"
        android:textColor="#fff"
        >
    </Button>

</RelativeLayout>


package com. example.e_commerce;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
private Button button;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_main );
button = findViewById( R.id.caa );
button.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, Signup.class );
startActivity( intent );
}
});
}
}

Second Activity:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <include
        android:id="@+id/toolbar"
        layout="@layout/activity_toolbar"
        >

    </include>
    <TextView
        android:id="@+id/Wamu"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="WAMU!"
        android:layout_marginTop="@dimen/_10sdp"
        android:layout_marginLeft="@dimen/_20sdp"
        android:textColor="#000"
        android:textSize="@dimen/_40sdp"
        android:textStyle="bold"
        android:layout_below="@id/toolbar"
        >

    </TextView>
    <EditText
        android:id="@+id/ph1"
        android:layout_width="match_parent"
        android:layout_height="@dimen/_40sdp"
        android:hint=" Name"
        android:drawableLeft="@drawable/name_1"
        android:textSize="@dimen/_20sdp"
        android:background="#fff"
        android:layout_marginLeft="@dimen/_20sdp"
        android:layout_marginRight="@dimen/_20sdp"
        android:layout_marginTop="@dimen/_10sdp"
        android:layout_below="@id/Wamu"
        android:textColor="#000"

        />


    <EditText
        android:id="@+id/number"
        android:layout_width="match_parent"
        android:layout_height="@dimen/_40sdp"
        android:hint=" Number"
        android:drawableLeft="@drawable/number_2"
        android:background="#fff"
        android:layout_below="@id/ph1"
        android:layout_marginLeft="@dimen/_20sdp"
        android:layout_marginRight="@dimen/_20sdp"
        android:layout_marginTop="@dimen/_20sdp"
        android:textColor="#000"
        android:textSize="@dimen/_20sdp"

        >
    </EditText>

    <EditText
        android:id="@+id/email"
        android:layout_width="match_parent"
        android:layout_height="@dimen/_40sdp"
        android:hint=" Email"
        android:drawableLeft="@drawable/email_sign"
        android:background="#fff"
        android:layout_below="@id/number"
        android:layout_marginLeft="@dimen/_20sdp"
        android:layout_marginRight="@dimen/_20sdp"
        android:layout_marginTop="@dimen/_20sdp"
        android:textColor="#000"
        android:textSize="@dimen/_20sdp"

        >
    </EditText>

    <EditText
        android:id="@+id/password"
        android:layout_width="match_parent"
        android:layout_height="@dimen/_40sdp"
        android:hint=" Password"
        android:inputType="textPassword"
        android:drawableLeft="@drawable/lock_open"
        android:background="#fff"
        android:layout_below="@id/email"
        android:layout_marginLeft="@dimen/_20sdp"
        android:layout_marginRight="@dimen/_20sdp"
        android:layout_marginTop="@dimen/_20sdp"
        android:textColor="#000"
        android:textSize="@dimen/_20sdp"
        >
    </EditText>

    <Button
        android:id="@+id/register"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#6A95CC"
        android:layout_marginLeft="@dimen/_40sdp"
        android:layout_centerInParent="true"
        android:layout_marginTop="@dimen/_40sdp"
        android:layout_below="@id/password"
        android:text="Register"
        android:textSize="@dimen/_20sdp"
        android:textColor="#fff"
        >
    </Button>
    <TextView
        android:id="@+id/or"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="OR"
        android:layout_centerInParent="true"
        android:layout_below="@id/register"
        android:layout_marginTop="@dimen/_10sdp"
        android:layout_marginBottom="@dimen/_10sdp"
        android:textSize="@dimen/_30sdp"
        android:textColor="#000"
        />
    <Button
        android:id="@+id/login"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#6A95CC"
        android:layout_marginLeft="@dimen/_40sdp"
        android:layout_centerInParent="true"
        android:text="Log in"
        android:layout_below="@id/or"
        android:textSize="@dimen/_20sdp"
        android:textColor="#fff"
        >
    </Button>
</RelativeLayout>
package com.example.e_commerce;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Signup extends AppCompatActivity {
    private Button button;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_signup);
        button = findViewById(R.id.register);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Signup.this, MainActivity.class);
                startActivity(intent);
            }
        });
    }
}
Login and registration form in android studio code-Programmer Knows Login and registration form in android studio code-Programmer Knows

/* Your code... */

2 thoughts on “Login and registration form Click on listener in android studio code”

  1. This is the right web site for everyone who would like to understand this topic. You understand a whole lot its almost tough to argue with you (not that I really will need to…HaHa). You definitely put a new spin on a topic that has been written about for decades. Excellent stuff, just excellent!

    Reply

Leave a Comment