free
web stats

Android – How to Start a New Activity with a Button Click

In this post, I’m going to show you how to open a new activity with a button that we created. We have 2 Activity and theirs screens. Click to main activity’s button, go second activity and click to second activity’s button, go to main activity.

Here is project structure;

Firstly we’re creating new empty project.

Add new Activity named SecondActivity. Then add new layout named second_activity.xml.

Then add these codes in AndroidManfest.xml;

Add these codes in MainActivity class;

 

Add these codes in SecondActivity class;

Add these codes in activity_main.xml

Add these codes in second_activity.xml;

It’s finish. Just run the project. Have a nice days 🙂

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *