Beginner often confuse about the structure of android project. They have no idea about what is inside SRC , RES and in other important folders of android project.Here we have some basic structure of android project .
When you first create an android project, your fresh project will look like this :
Image may be NSFW.
Clik here to view.
Lets explore what is inside the different folder .
Click on SRC (SourceFolder) you will find different .java file in it. By default there is only one .java file i.e MainActivity.java in which you right your main program and call other sub .java files .
Image may be NSFW.
Clik here to view.
Another folder is Res (Resource Folder) , which have all drawable items, e.g Images, mpe files and all other. Inside RES folder there is a sub-folder known as ”layout” , which contains the “activity_main.xml” file. You can create User Interface in this file by drag and drop the items ( in Graphical Layout) or by writing a actual content code (in Activity_main.xml ) you create it.
Image may be NSFW.
Clik here to view.
In above figure you will see the color world of UI, you can also see how your app will look like on different device by choose the device that you want.
Image may be NSFW.
Clik here to view.
For example i want to know how my application on will look like on Nexus 4, so i will select Nexus 4 .
Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.
Now Lets examine what is inside Main_activity.xml. Double click on “Main_activity.xml” . Here you will see Main_activity.xml window.
Image may be NSFW.
Clik here to view.
Here i have my layout all it has is single TextView with “Hello World ” as a text . The text string is stored in another file. You can edit this string and add or change the string independently of the layout but where is that file . This is a “String.xml” file inside “values” folder.
Image may be NSFW.
Clik here to view.
Double click “String.xml” file
Image may be NSFW.
Clik here to view.
To change “Hello World “string to another say “Hello Awesome World”, double click on it and change it as:
Image may be NSFW.
Clik here to view.
If you want to write text in multiple line , use “\n” .Instead for using “>” for greater than and “<” for less than use “>” and “<” respectively.
Image may be NSFW.
Clik here to view.
Lets save that and go back to layout.
Image may be NSFW.
Clik here to view.
Another Important file is “AndroidManifest.xml” file .AndroidManifest.xml is the description of what my application is. So it contains the list of all activities and all the security item that my app needs access and also contains the permission and privilege e.g permission to get data from GPS, send/receive call etc
This was the basic structure of android project for beginners who want to learn android from scratch . In next article i will tell you some advance concept e.g Localization and images in android.