Android2.33 应用程序工程目录分析


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资源类中的布局属性。

  1. package com.test;  
  2.   
  3.    
  4.   
  5. import android.app.Activity;  
  6.   
  7. import android.os.Bundle;  
  8.   
  9. import android.view.Gravity;  
  10.   
  11. import android.view.View;  
  12.   
  13. import android.widget.Button;  
  14.   
  15. import android.widget.TextView;  
  16.   
  17. import android.widget.Toast;  
  18.   
  19.    
  20.   
  21. public class HelloWorldActivity extends Activity {  
  22.   
  23.     /** Called when the activity is first created. */  
  24.   
  25.     @Override  
  26.   
  27.     public void onCreate(Bundle savedInstanceState) {  
  28.   
  29.         super.onCreate(savedInstanceState);  
  30.   
  31.         setContentView(R.layout.main);  
  32.   
  33.     }  
  34.   
  35. }  

2)        gen目录

本目录存放的是工程资源索引文件 R.java,该类由系统自动生成,根据不同的资源类型又包含了不同的静态内部类。

a)         attr静态类声明属性;

b)        drawable静态类声明图片资源;

c)         layout静态类声明布局文件;

d)        string静态类声明字符串;

e)         id静态类声明界面中使用的组件;

  1. /* AUTO-GENERATED FILE.  DO NOT MODIFY. 
  2.  
  3.  * 
  4.  
  5.  * This class was automatically generated by the 
  6.  
  7.  * aapt tool from the resource data it found.  It 
  8.  
  9.  * should not be modified by hand. 
  10.  
  11.  */  
  12.   
  13.    
  14.   
  15. package com.test;  
  16.   
  17.    
  18.   
  19. public final class R {  
  20.   
  21.     public static final class attr {  
  22.   
  23.     }  
  24.   
  25.     public static final class drawable {  
  26.   
  27.         public static final int clwf=0x7f020000;  
  28.   
  29.         public static final int icon=0x7f020001;  
  30.   
  31.     }  
  32.   
  33.     public static final class id {  
  34.   
  35.         public static final int btn=0x7f050001;  
  36.   
  37.         public static final int textview1=0x7f050000;  
  38.   
  39.     }  
  40.   
  41.     public static final class layout {  
  42.   
  43.         public static final int main=0x7f030000;  
  44.   
  45.     }  
  46.   
  47.     public static final class string {  
  48.   
  49.         public static final int app_name=0x7f040001;  
  50.   
  51.         public static final int hello=0x7f040000;  
  52.   
  53.     }  
  54.   
  55. }  
  • 1
  • 2
  • 3
  • 下一页

相关内容