How to create a register activity in Android?

No Comments

Step 1: Create a blank activity under your java class. Give the name of the activity as RegisterActivity and check the box of fragments while creating the register activity.


Step 2: In your MainActivity declare the register button and define it by using the following code:

Button registerbutton = (Button) findViewById(;

Here button3 is the id of the register button.


Step 3: in the fragment_register.xml file give the fields that you want in your register screen by using EditText and TextView. This can be done as follows:

android:layout_height=“wrap_content” />
android:layout_height=“wrap_content” /> <TextView
android:layout_height=“wrap_content” />
android:layout_height=“wrap_content” />

TextView gives the name of the field that you want to display. And the EditText is where you can enter your data , which here is the email and password.

Like this many other fields can also be added to your register screens.

To add a functionality of registering n clicking the button add the below code in your java file.

registerbutton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final Intent registerIntent = new Intent().setClass(LandingPageActivity.this, RegisterActivity.class);

The register button is available on our MainActivity page , which is the landing page here. So when the register button is pressed the setOnClickListener event is called and the register screen appears and you can enter the user’s details there and press the register button at the bottom of the screen to register.

Your screen will look like this:


About us and this blog

We are a digital marketing company with a focus on helping our customers achieve great results across several key areas.

Request a free quote

We offer professional SEO services that help websites increase their organic search score drastically in order to compete for the highest rankings even when it comes to highly competitive keywords.

Subscribe to our newsletter!

More from our blog

See all posts

Leave a Comment