In this lesson you'll learn to add a second Activity to your app. Run this app. We have added this new layout file sub.xml for the new activity. We have also added this new Java class SubActivity for the new activity which sets sub.xml as the content. In the App Manifest add a new activity element with no attributes yet. Add android:label to the activity element with value Compose email. This will be the title of the new activity. Add android:theme to the activity element with value @android:style/Theme.Holo.Light. Add android:name to the activity element with value .SubActivity, to tell the system that the SubActivity Java class will handle the activity. To start the new activity in the onComposeButtonClick method via an intent, pass this as a context and SubActivity.class as the activity class to the Intent constructor.
Now call startActivity() and pass the intent. Congratulations! You've learned to add activities to your app. Play with the code on your own a bit.
REQUIREMENTS:
Download:
Eclipse
Instruction:
After you download all the files needed in this tutorial, we need to install and set-up a java JDK path to our environment variables, the step below will show you how.
--Go to Java JDK installation directory in "C:\Program Files\Java\jdk1.7.0\bin" Copy this path
--Go to the environment path by Clicking: Window taskbar--->right click Computer--->Click Advance System setting ---> then go to Advanced tab Then select "Environment Variable" then create new Variable name and variable value by clicking the New radio button. Within the "Variable name" input these "JAVA_HOME" then in the "Variable value" point it to your C:\Program Files\Java\jdk1.7.0\bin
that's it we are on a way of creating our first game and deploy it to a different platform.
After that we will also set-up Android SDK, to its path by extracting first it to the directory you want for example in "drive D:" or "drive C:" once we did this, we can now copy the root folder of this SDK which is likely to this format "D:\Android SDK" copy it then add it also to the "Environment path" like what you did before in "Java JDK".
COMPLETE CODES
MAIN ACTIVITY CODE
SUB ACTIVITY CODE
MAIN XML CODE
SUB XML CODE
ANDROID MANIFEST XML CODE
COMPLETE CODES
MAIN ACTIVITY CODE
SUB ACTIVITY CODE
MAIN XML CODE
SUB XML CODE
ANDROID MANIFEST XML CODE
0 Comments