Chinaunix首页 | 论坛 | 博客
  • 博客访问: 208008
  • 博文数量: 102
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1015
  • 用 户 组: 普通用户
  • 注册时间: 2013-06-05 16:45
文章存档

2014年(73)

2013年(29)

我的朋友

分类: Android平台

2013-12-09 23:50:26

01_03_say_hello_to_Android
1、创建一个Android应用程序的步骤
2、Android应用程序的目录结构
    src目录:存放源代码
    gen目录:由SDK自动产生。其中R.java文件是资源文件
    

点击(此处)折叠或打开

  1. /* AUTO-GENERATED FILE. DO NOT MODIFY.
  2.  *R.java文件
  3.  * This class was automatically generated by the
  4.  * aapt tool from the resource data it found. It
  5.  * should not be modified by hand.
  6.  */

  7. package com.lwb.myhelloword;

  8. public final class R {
  9.     public static final class attr {
  10.     }
  11.     public static final class dimen {
  12.         /** Default screen margins, per the Android Design guidelines.

  13.          Customize dimensions originally defined in res/values/dimens.xml (such as
  14.          screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
  15.     
  16.          */
  17.         public static final int activity_horizontal_margin=0x7f040000;
  18.         public static final int activity_vertical_margin=0x7f040001;
  19.     }
  20.     public static final class drawable {
  21.         public static final int ic_launcher=0x7f020000;
  22.     }
  23.     public static final class id {
  24.         public static final int action_settings=0x7f080000;
  25.     }
  26.     public static final class layout {
  27.         public static final int activity_hello=0x7f030000;
  28.     }
  29.     public static final class menu {
  30.         public static final int hello=0x7f070000;
  31.     }
  32.     public static final class string {
  33.         public static final int action_settings=0x7f050001;
  34.         public static final int app_name=0x7f050000;
  35.         public static final int hello_world=0x7f050002;
  36.     }
  37.     public static final class style {
  38.         /**
  39.         Base application theme, dependent on API level. This theme is replaced
  40.         by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
  41.     

  42.             Theme customizations available in newer API levels can go in
  43.             res/values-vXX/styles.xml, while customizations related to
  44.             backward-compatibility can go here.
  45.         

  46.         Base application theme for API 11+. This theme completely replaces
  47.         AppBaseTheme from res/values/styles.xml on API 11+ devices.
  48.     
  49.  API 11 theme customizations can go here.

  50.         Base application theme for API 14+. This theme completely replaces
  51.         AppBaseTheme from BOTH res/values/styles.xml and
  52.         res/values-v11/styles.xml on API 14+ devices.
  53.     
  54.  API 14 theme customizations can go here.
  55.          */
  56.         public static final int AppBaseTheme=0x7f060000;
  57.         /** Application theme.
  58.  All customizations that are NOT specific to a particular API-level can go here.
  59.          */
  60.         public static final int AppTheme=0x7f060001;
  61.     }
  62. }
    Android 4.2目录:
       其中有这样的一个android.jar 路径是在D:\swpaket\study\adt-bundle-windows-x86-20130729\adt-bundle-windows-x86-20130729\sdk\platforms\android-18\android.jar
        表明:android应用的所有类文件均来源于android.jar中(这个含有很多的包)
    Android Private Libraries目录(该目录下有两个目录)
          Android  Dependencies目录:
           asserts目录:(放置任何文件)
    res目录:(在该目录下放置的任何文件,均会在R.java中产生一个id,可以通过这个id来使用这个文件)
        drawable(-hdpi,-ldpi,-mdpi,三个版本的分辨率的图片等)目录:
        layout:(放置布局布局文件main.xml,控制各种控件在Activity中的布局)
        values:(如:string.xml)
        如:string.xml  里边的键值也会在R.java中有唯一的id号

点击(此处)折叠或打开

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <resources>

  3.     <string name="app_name">myhelloword</string>
  4.     <string name="action_settings">Settings</string>
  5.     <string name="hello_world">Hello world!</string>

  6. </resources>



3、AndroidManifest.xml文件的作用  (
  • Manfiest的意思:
  • n. 载货单,货单;旅客名单
    • adj. 显然的,明显的;明白的
      • vt. 证明,表明;显示
      • vi. 显示,出现


        AndroidManifest.xml整个程序的配置文件

点击(此处)折叠或打开

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android=""
  3.     package="com.lwb.myhelloword"      
  4.     android:versionCode="1"
  5.     android:versionName="1.0" >

  6.     <uses-sdk
  7.         android:minSdkVersion="10"  
  8.         android:targetSdkVersion="17" />

  9.     <application    
  10.         android:allowBackup="true"
  11.         android:icon="@drawable/ic_launcher"    
  12.         android:label="@string/app_name"        
  13.             android:name="com.lwb.myhelloword.HelloActivity"  
  14.             android:label="@string/app_name" >
  15.             <intent-filter>                      
  16.                 <action android:name="android.intent.action.MAIN" />

  17.                 <category android:name="android.intent.category.LAUNCHER" />
  18.             </intent-filter>
  19.         </activity>
  20.     </application>

  21. </manifest>


4、Android相关资源文件的作用
阅读(367) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~