Initial knowledge of the simplest Android application directory structure

Source: Internet
Author: User

It is important to recognize the Android directory structure. Like words are as important as learning a language. In the future to learn the Android kernel source code, but also the first need to familiarize themselves with the Android source directory structure. Just start to learn the directory structure, naturally there may be more boring, which can be constantly familiar at the time, the continuous summary as the name implies (SRC, source code) The folder is put project source code. Opening the Helloworld.java file will see the following code:.

The simplest HelloWorld application directory structure:

1,SRC directory:

Src:source Code The folder is the source code for the project. Opening the Helloworld.java file will see the following code:

1  Packagehelloworld.test;2 3 Importandroid.app.Activity;4 ImportAndroid.os.Bundle;5 6  Public classHelloWorldextendsActivity {7     /**Called when the activity is first created.*/8 @Override9      Public voidonCreate (Bundle savedinstancestate) {Ten         Super. OnCreate (savedinstancestate); One Setcontentview (r.layout.main); A     } -}

This helloworld.java is the entrance to the application that we refer to ourselves often.

2,gen directory:

There is a R.java file under the folder, and R.java is generated automatically when you build the project. The R.java file defines a class--r,r class that contains many static classes, and the name of the static class corresponds to a name in Res, which is the R class that defines the index of all resources for the project.

3,assets directory:

You need to package the resource files (non-code) into the application, such as MP3, video class files, and so on.

4,res directory:

Resource folders, such as the string resources that your application requires, layout file resources, and so on, such as layout files:

1 <?xml version= "1.0" encoding= "Utf-8"?> 2 <linearlayout xmlns:android= "/http Schemas.android.com/apk/res/android " 3     android:orientation=" Vertical " 4     android:layout _width= "Fill_parent" 5     android:layout_height= "Fill_parent" 6     > 7 <  TextView    8      9          android:text= "@string/hello"11      /> </LinearLayout>

5, configuration file Androidmanifext.xml:

This file is the most important, documenting the various components used in the application. The equivalent of the application contains the declaration of the various functions, when the Android run, will read the file, and then execute the corresponding components inside.

1<?xml version= "1.0" encoding= "Utf-8"?>2<manifest xmlns:android= "Http://schemas.android.com/apk/res/android"3        Package= "Helloworld.test"4Android:versioncode= "1"5Android:versionname= "1.0" >6<application android:icon= "@drawable/icon" android:label= "@string/app_name" >7<activity android:name= ". HelloWorld "8Android:label= "@string/app_name" >9<intent-filter>Ten<action android:name= "Android.intent.action.MAIN"/> One<category android:name= "Android.intent.category.LAUNCHER"/> A</intent-filter> -</activity> -</application> the</manifest>

6,bin directory:

After we execute our code, we will generate the corresponding executable file in the bin directory, we go to this directory to fetch the corresponding apk.

Initial knowledge of the simplest Android application directory structure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.