In this example, I will show how to start a new activity(new screen) when a button is clicked in android application. Here, if you click the click me button, you will see the new activity(second activity).

How to Change Android Button on Click/Press Color
How to Set Android Button and TextView Border Color
How to Add Ripple Effect/Animation to a Android Button

XML Layout File
Add the following xml code in your activity_main.xml file.

Now, create a new xml layout called activity_second.xml and add following.

Java Activity File
Following is the java code of MainActivity.java file.

Again, create a new java file called SecondActivity.java and add following code.

AndroidManifest.xml File
Following is the final code of AndroidManifest.xml file.

Now, run your application and click the click me button, you will see the new activity.

Start New Activity When Button is Clicked in Android
Start New Activity

Post a Comment

Powered by Blogger.