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).
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.
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|