This is a detailed explanation of the last article regarding android app creation. You can find that article here.

In this Android tutorial you will learn:
- where the project files are located
- define the roles of the project files
- what files create the application’s user interface (UI)
- what files are used for programming the app’s functionality
- understand the programming concepts of this app
Project Files
Since this is a beginners tutorial, it’s good to know what and where the various files were produced to create this simple Hello World app. To find out where the files are produced from your Eclipse editor, just go to Project | Properties and a similar screen found below should appear.

From this screen, look at the location field and there you should find the location of your Hello World android app. In this example, it is /home/htmlpress/workspace-android/Hello World. There are five folders and three files on the main project folder.
Folders:
- assets – does not contain anything for this project.
- bin – contains the binary files i.e. the .apk file. APK files are what you submit to the Google Play website so that others can download your app.
- gen – folders and the file generated here are not to be modified by hand so we shall leave this alone. Contains the R.java file which is an index to all the resources used by your app to which you can refer in your source code.
- res – contains folders and files that renders the look and feel of your app.
- src – contains the java source code of the Hello World app
Files:
- AndroidManifest.xml
- proguard.cfg
- project.properties
These three files are text files.
You should be able to see most, if not all, of these folders and files from your Eclipse editor.
User Interface
The files that construct the user interface for this Hello World android app are found in the res > layout > main.xml in the Package Explorer frame of Eclipse.

The screen above shows the graphical layout of the Hello World app. To look at the code just click on the tab on the lower left hand side called main.xml. You should see the following code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
</LinearLayout>
So from this code, we can find out that the Linear Layout is used and that a TextView object called hello is used to display a string. This is defined in the TextView tag and the android:text attribute of the mentioned tag. With Android, there are different types of layout you can use which will be the topic of future posts. For now we just want to understand the Hello World app.
To find out the value for the TextView tag, open the file res > values > strings.xml in the Project Explorer frame of Eclipse. You should see the following code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, HelloWorldActivity!</string>
<string name="app_name">Hello World</string>
</resources>
You can then compare the string values here from the AVD screen shot above. From here you can make out where the text comes from. If you plan to do some layout changes, then Google strongly encourages developers to make changes from the two xml layout files mentioned above. This makes your code more readable and lessens the complexity of a mobile app.
Programmatic Source Code
The programmatic code for this Hello World mobile app is found in src > net.htmlpress.helloworld > HelloWorldActivity.java of your Eclipse’s Package Explorer frame. The code should look like the following:
package net.htmlpress.helloworld;
import android.app.Activity;
import android.os.Bundle;
public class HelloWorldActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
In this code, there is one class – HelloWorldActivity – which is based on the Activity class. In an Android, an Activity is a single application entity that have functions being performed. An application can have more than one Activity where the user can use each one at a time. In this app it only has one. It’s only function is to display a message. An activity can have a user interface or can just run in the background without a UI.
The onCreate method is an event that gets triggered when your application starts. Thus, any code defined in this method get executed when your application starts. Below is a diagram illustrating the various events in an Android application.
The code super.onCreate(savedInstanceState) ensures that the Android state prior to executing your app is saved. Without this, you’ll be getting an unexpected error while starting your application (applies to the version of Android used in this tutorial).
The code setContentView(R.layout.main) sets the Activity’s user interface. Omitting this line of code will give you a blank screen. you would still get the title bar through with the text Hello World. But the layout that includes the Text View object are not included. The setContentView received a view object as a parameter. And the view passed is the desired content to display.


Comments are closed.