button click create multiple new activities android studio

Button Click Create Multiple New Activities Android Studio

Button Click Create Multiple New Activities Android Studio – In this tutorial i will show you how to create new activity when click the button and create multiple activities in android studio. Most of beginners struggle to create new activities in button click activity so here i will explain only create multiple activities when user click the button.

This is basics of every android application so surely you need some ideas for develop the code in create button click activities. Its very simple just integrate XML files with Java classes into create new activity when user click button activity in android application example.

Button Click Create Multiple Activities Android Studio

Let’s start start our project to make activities when the user click the button actions. First Create New Project and choose Empty Activity after creating the project open the default class of MainActivity.java file and add the following code,

MainActivity.java

After writing the code of MainActivity.java file create another class when user click the button activity open the second activity files in your android example project. So here just create SecondActivity.java class file and add the following code,

SecondActivity.java

Now the SecondActivity.java file is created after that we create another activity actions when user click another activity files. In this project we create more activity layout files, user click button actions android navigate multiple activities. Finally create class of ThirdActivity.java file and add the following code,

ThirdActivity.java

Java classes are over. Hereafter need to create XML files integrate Java classes to make button click activity android when user click button action open the new activity layouts.

Activity Layouts

In this project we need three XML layout files as like java class files, because in this project we create multiple (three) activity files when user click the button action. So just create two more xml files and give some name for that and call from the same name in java files. Open under the path of res=>layout=>activity_main.xml file and add the following code,

After that create activity_second.xml file and add the following code below,

Finally create the activity_third.xml file and add the following code below,

That’s all, now run your button click open new activity android example in your virtual device or any other android mobile device.

Download Code

Click to get the full Source code of Button Click create New Activity files in Android example.

button click create multiple new activities android studio

Demo Video

This is J.Vetrivel pandian completed MCA & lives in Udangudi,India. Blogging is my Passion, I love to write article about Programming. Apart from blogging, I’ll run Grocery Store that’s my Profession.