1、src目錄是源代碼目錄,所有允許用戶修改的java文件和用戶自己添加的java文件都保存在這個目錄中
2、gen目錄是1.5版本新增的目錄,用來保存ADT自動生成的java文件,例如R.java或AIDL文件
註意:R.java文件(非常重要)
a) R.java文件是ADT自動生成的文件,包含對drawable、layout和values目錄內的資源的引用指針,Android程序能夠直接通過R類引用目錄中的資源
b) R.java文件不能手工修改,如果向資源目錄中增加或刪除瞭資源文件,則需要在工程名稱上右擊,選擇Refresh來更新R.java文件中的代碼
c) R類包含的幾個內部類,分別與資源類型相對應,資源ID便保存在這些內部類中,例如子類drawable表示圖像資源,內部的靜態變量icon表示資源名稱,其資源ID為0x7f020000。一般情況下,資源名稱與資源文件名相同
3、android.jar文件是Android程序所能引用的函數庫文件,Android通過平臺所支持API都包含在這個文件中
4、assets目錄用來存放原始格式的文件,例如音頻文件、視頻文件等二進制格式文件。此目錄中的資源不能被R.java文件索引。,所以隻能以資截流的形式讀取。一般情況下為空
5、main.xml文件,是界面佈局文件,利用XML語言描述的用戶界面
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
6、Strings.xml文件是程序中的一些字符串的引用
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, HelloAndroid!</string>
<string name="app_name">HelloAndroid</string>
</resources>
7、AndroidManifest.xml是XML格式的Android程序聲明文件,包含瞭Android系統運行Android程序前所必須掌握的重要信息,這些信息包含應用程序名稱、圖標、包名稱、模塊組成、授權和SDK最低版本等,而且每個Android程序必須在根目錄下包含一個AndroidManifest.xml文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edu.hrbeu.HelloAndroid"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon"
android:label="@string/app_name">
<activity android:name=".HelloAndroid"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
</manifest>
註:AndroidMainfest.xml文件:
1) AndroidManifest.xml文件的根元素是manifest,包含瞭xmlns:android、package、android:versionCode和android:versionName共4個屬性
2) xmlns:android定義瞭Android的命名空間,值為http://schemas.android.com/apk/res/android
3) package定義瞭應用程序的包名稱
4) android:versionCode定義瞭應用程序的版本號,是一個整數值,數值越大說明版本越新,但僅在程序內部使用,並不提供給應用程序的使用者
5) android:versionName定義瞭應用程序的版本名稱,是一個字符串,僅限於為用戶提供一個版本標識
6) manifest元素僅能包含一個application元素,application元素中能夠聲明Android程序中最重要的四個組成部分,包括Activity、Service、BroadcastReceiver和ContentProvider,所定義的屬性將影響所有組成部分
7) 第6行屬性android:icon定義瞭Android應用程序的圖標,其中@drawable/icon是一種資源引用方式,表示資源類型是圖像,資源名稱為icon,對應的資源文件為res/drawable目錄下的icon.png
8) 第7行屬性android:label則定義瞭Android應用程序的標簽名稱
8、default.properties文件記錄Android工程的相關設置,該文件不能手動修改,需右鍵單擊工程名稱,選擇“Properties”進行修改
摘自:jiahui524專欄