Continued from the Part - 1 ...
Step 1 : So you may are now able to see this page.
Step 2 : Now click activity_main.xml circled in the image above . You will see the xml code of your application .
The xml file is situated in MyFirstProject ->res -> layout folder (circled in above image)
The xml files contains two elements A <RelativeLayout> and a <TextView>
A layout defines how the elements are placed in a page (defines the orientation of elements).
TextView contains the text you want to display on the screen .
(Try to change the Hello world text to your name and look at the GraphicalLayout).
Step 3 : Double click on src -> com.example.MyFirstProject -> MainActivity.java
The java file named MainActivity.java will be opened.
You will find the following elements in it .
Step 1 : So you may are now able to see this page.
Step 2 : Now click activity_main.xml circled in the image above . You will see the xml code of your application .
The xml file is situated in MyFirstProject ->res -> layout folder (circled in above image)
The xml files contains two elements A <RelativeLayout> and a <TextView>
A layout defines how the elements are placed in a page (defines the orientation of elements).
TextView contains the text you want to display on the screen .
(Try to change the Hello world text to your name and look at the GraphicalLayout).
Step 3 : Double click on src -> com.example.MyFirstProject -> MainActivity.java
The java file named MainActivity.java will be opened.
You will find the following elements in it .
- package name ( package com.example.MyFirstProject)
- List of imports(Click on + button besides the import).
- MainActivity class which extends Activity .
- An onCreate method with a Bundle type argument .
- A predefined class called setContentView(R.layout.activity_main) which takes argument as xml file (activity_main.xml).
- Ignore the method onCreateOptionsMenu since it does not have effect on the execution of the app if you delete it .
Step 5 :
Check the line android:name="com.example.myfirstproject.MainActivity" which has name of our class MainActivity, hence MainActivity class will be executed first .
Also check on the line which says <action android:name="android.intent.action.MAIN" /> .MAIN says that it is the page which is going to be launched at the first place .
Step 6 : You will see a Android mobile popped up called the Emulator .
Check the Console marked above to see the activities running on the emulator .
Step 7 : After some time the mobile screen will be seen. Just drag the lock screen and the application will be seen with Hello World returned on the screen. (Wait till the application loads on the screen) .
And you have made an android application.....Congratulations.
Stay tuned with Made In Android