HelloWorld程序工程目錄結構
1) src目錄
2) gen目錄
3) Android 2.3.3
4) assets目錄
5) res/drawable目錄
6) res/layout目錄
7) res/values
8) AndroidManifest.xml
9) default.properties
10) proguard.cfg
HelloWorld程序工程目錄結構
1) src目錄
本目錄下存放的Android應用程序的Java源代碼,HelloWorldActivity類繼承了Activity類,並覆蓋onCreate()方法,在該方法中調用父類的構造方法,然後調用setContentView()方法展示視圖界面。R.layout.main是R.java資源類中的布局屬性。
- package com.test;
-
-
-
- import android.app.Activity;
-
- import android.os.Bundle;
-
- import android.view.Gravity;
-
- import android.view.View;
-
- import android.widget.Button;
-
- import android.widget.TextView;
-
- import android.widget.Toast;
-
-
-
- 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);
-
- }
-
- }
2) gen目錄
本目錄存放的是工程資源索引文件 R.java,該類由系統自動生成,根據不同的資源類型又包含了不同的靜態內部類。
a) attr靜態類聲明屬性;
b) drawable靜態類聲明圖片資源;
c) layout靜態類聲明布局文件;
d) string靜態類聲明字符串;
e) id靜態類聲明界面中使用的組件;
- /* AUTO-GENERATED FILE. DO NOT MODIFY.
-
- *
-
- * This class was automatically generated by the
-
- * aapt tool from the resource data it found. It
-
- * should not be modified by hand.
-
- */
-
-
-
- package com.test;
-
-
-
- public final class R {
-
- public static final class attr {
-
- }
-
- public static final class drawable {
-
- public static final int clwf=0x7f020000;
-
- public static final int icon=0x7f020001;
-
- }
-
- public static final class id {
-
- public static final int btn=0x7f050001;
-
- public static final int textview1=0x7f050000;
-
- }
-
- public static final class layout {
-
- public static final int main=0x7f030000;
-
- }
-
- public static final class string {
-
- public static final int app_name=0x7f040001;
-
- public static final int hello=0x7f040000;
-
- }
-
- }