zoukankan      html  css  js  c++  java
  • Android之项目的目录结构

    本篇将介绍Android项目的目录结构。本文的主要主题如下:

    • 1、jieche项目的目录结构
      • 1.1、src文件夹
      • 1.2、libs文件夹
      • 1.3、res文件夹
      • 1.4、AndroidManifest.xml
      • 1.5、R.java文件

    1.1、src文件夹

      顾名思义(src, source code)该文件夹是放项目的源代码的。打开文件夹会看到如下:

      java文件夹下面的就是项目的源代码

    1.2、libs文件夹

      包含可以给应用程序调用的第三方类库

    1.3、res文件夹

      资源目录,包含你项目中的资源文件并将编译进应用程序。向此目录添加资源时,会被R.java自动记录。新建一个项目,res目录下会有三个子目录:drawabel、layout、values。

    • drawabel-?dpi:包含一些你的应用程序可以用的图标文件(*.png、*.jpg);
    • layout:界面布局文件(main.xml)与WEB应用中的HTML类同;
    • values:软件上所需要显示的各种文字。可以存放多个*.xml文件,还可以存放不同类型的数据。比如arrays.xml、colors.xml、dimens.xml、styles.xml

    1.4、AndroidManifest.xml

      项目的总配置文件,记录应用中所使用的各种组件。这个文件列出了应用程序所提供的功能,在这个文件中,你可以指定应用程序使用到的服务(如电话服务、互联网服务、短信服务、GPS服务等等)。另外当你新添加一个Activity的时候,也需要在这个文件中进行相应配置,只有配置好后,才能调用此Activity。AndroidManifest.xml将包含如下设置:application permissions、Activities、intent filters等。

    AndroidManifest.xml就是用来存储一些数据的,只不过这些数据时关于android项目的配置数据。

      项目的AndroidManifest.xml如下所示:

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     3     package="com.harsons.jieche.activity" >
     4     <application
     5         android:allowBackup="true"
     6         android:icon="@drawable/ic_launcher"
     7         android:label="@string/app_name"
     8         android:theme="@style/AppTheme" >
     9         <activity
    10             android:name="com.harsons.jieche.activity.MainActivity"
    11             android:label="@string/app_name" >
    12             <intent-filter>
    13                 <action android:name="android.intent.action.MAIN" />
    14                 <category android:name="android.intent.category.LAUNCHER" />
    15             </intent-filter>
    16         </activity>
    17         <activity
    18             android:name="com.harsons.jieche.activity.BespeakActivity"
    19             android:label="@string/title_activity_bespeak" >
    20         </activity>
    21         <activity
    22             android:name="com.harsons.jieche.activity.CarsActivity"
    23             android:label="@string/title_activity_cars" >
    24         </activity>
    25         <activity
    26             android:name="com.harsons.jieche.activity.ClientActivity"
    27             android:label="@string/title_activity_client" >
    28         </activity>
    29         <activity
    30             android:name="com.harsons.jieche.activity.LoginActivity"
    31             android:label="@string/title_activity_login" >
    32         </activity>
    33         <activity
    34             android:name="com.harsons.jieche.activity.RenderActivity"
    35             android:label="@string/title_activity_render" >
    36         </activity>
    37         <activity
    38             android:name="com.harsons.jieche.activity.SelClientActivity"
    39             android:label="@string/title_activity_sel_client" >
    40         </activity>
    41         <service android:name="com.harsons.jieche.service.MainService" >
    42         </service>
    43         <activity
    44             android:name="com.harsons.jieche.activity.JiecheRegActivity"
    45             android:label="@string/title_activity_jieche_reg" >
    46         </activity>
    47     </application>
    48     <uses-permission android:name="android.permission.INTERNET" />
    49 </manifest>
    View Code

    1.5、R.java文件在build文件夹下,如图:

      R.java是在建立项目时自动生成的,这个文件是只读模式的,不能更改。R.java文件中定义了一个类——R,R类中包含很多静态类,且静态类的名字都与res中的一个名字对应,即R类定义该项目所有资源的索引。如下图:

    R图2、R.java对应res

      通过R.java我们可以很快地查找我们需要的资源,另外编绎器也会检查R.java列表中的资源是否被使用到,没有被使用到的资源不会编绎进软件中,这样可以减少应用在手机占用的空间。

  • 相关阅读:
    Serialization and deserialization are bottlenecks in parallel and distributed computing, especially in machine learning applications with large objects and large quantities of data.
    Introduction to the Standard Directory Layout
    import 原理 及 导入 自定义、第三方 包
    403 'Forbidden'
    https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
    These interactions can be expressed as complicated, large scale graphs. Mining data requires a distributed data processing engine
    mysqldump --flush-logs
    mysql dump 参数
    mysql dump 参数
    如果是在有master上开启了该参数,记得在slave端也要开启这个参数(salve需要stop后再重新start),否则在master上创建函数会导致replaction中断。
  • 原文地址:https://www.cnblogs.com/myxiaoQ/p/3658591.html
Copyright © 2011-2022 走看看