Android Basics Using AIDE 2


-

Android Basics Using AIDE 2
Understanding the three important files in Android Development
0) Preparation
1) Open basic files using Sublime
2) AndroidManifest.xml
3) MainActivity.java
4) main.xml

0) Preparation

1) Open basic files using Sublime

1.1) Look at the Project Folder and find AndroidManifest.xml, MainActivity.java and main.xml

2) AndroidManifest.xml

This file defines the structure and metadata of your android application and its components - Read http://developer.android.com/guide/topics/manifest/manifest-intro.html 
refer to line no.17, you can also write android:name="com.mycompany.myapp.MainActivity" .
As a shorthand, if the first character of the string is a period, the string is appended to the application's package name.
The statement tells the Android that the java class for the activity is MainActivity.java.

3) MainActivity.java

Package Name
Android follows normal java package conventions
The reason for having it in reverse order is to do with the layout on the storage media.
Import Statement
The import statement imports types from a package by telling the compiler where to look for unqualified type names during compilation.
android.app.* - Contains high-level classes encapsulating the overall Android application model eg activity
android.os.* - Provides basic operating system services, message passing, and inter-process communication on the device.
android.view.* - Provides classes that expose basic user interface classes that handle screen layout and interaction with the user.
android.widget.*
Java class MainActivity extends from Activity class. Readhttp://developer.android.com/reference/android/app/Activity.html 
In this example, MainActivity is using onCreate method of the Activity class. Readhttp://developer.android.com/reference/android/app/Activity.html#onCreate(android.os.Bundle) 
Refer line no.15, MainActivity is calling a layout resource file named main.xml.

4) main.xml



-

Post a Comment

0 Comments