So far we have created the Helloworld app and learned the Basic structure of an android app. Now we are going to learn about adding new activity to our android app.So in this tutorial let us learn about creating a new activity to your android application
STEP 1:
In your Main Application project, go to your
STEP 2:
Set Activity Name and Layout Name and Click finish
Let us see it in next post..
Activities
Activities are one of the fundamental building blocks of apps on the Android platform. They serve as the entry point for a user's interaction with an app, and are also central to how a user navigates within an app (as with the Back button) or between apps (as with the Recents button).See more about activities and its lifecycle here!
STEP 1:
In your Main Application project, go to your
java folder (src > main) > right click either the java folder or a package name > New > Activity>Blank Activity.STEP 2:
Set Activity Name and Layout Name and Click finish
Now you can see a new activity with name MainActivity2.java and its layout activity_main_activity2.xml. So we have successfully created our new activity and its layout.
Double click on your Androidmanifest.xml file
Double click on your Androidmanifest.xml file
You can see your new activity is declared in the manifest file.So android studio automatically declare its activities (if you select Activity in step 1).Without declaring activities in the manifest you wont have the permission to open your new activity.It will result in app crash.
Now you learned to create new activity in your project.On opening your app you can see only MainActivity(Which is declared as launcher activity in manifest). But how to go to your new activity from main activity?
Let us see it in next post..



No comments:
Post a Comment