Quantcast
Channel: CodesMeshCodesMesh
Viewing all articles
Browse latest Browse all 21

Structure Of Android Project

$
0
0

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 :

new pro

 

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 .

javafile

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.

xml

 

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.

device

 

For example i want to know how my application on will look like on Nexus 4, so i will select Nexus 4 .

nexus 7

 

nexux 4

Now Lets examine what is inside Main_activity.xml. Double click on “Main_activity.xml” . Here you will see Main_activity.xml window.

layout

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.

string

Double click “String.xml” file

stringname

To change “Hello World “string to another say “Hello Awesome World”, double click on it and change it as:

awsome world

 

If you want to write text in multiple line , use “\n” .Instead for using “>” for greater than and “<” for less than use “&gt” and “&lt” respectively.

less than

 

Lets save that and go back to layout.

next line cmd

 

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.


Viewing all articles
Browse latest Browse all 21

Trending Articles