Android 的專案結構 -- 解析 HelloWorld 當中的檔案

Android

簡介

使用方法

開發工具

開始寫程式

視覺化介面

視覺元件

對話元件

核心物件

事件處理

資料儲存

查詢功能

影音功能

繪圖功能

網路功能

衛星地圖

特殊功能

資源管理

裝置管理

系統核心

問題與回答

刷機升級

常用軟體

Eclipse

教學錄影

訊息

相關網站

參考文獻

最新修改

簡體版

English

專案下載:HelloWorld.zip

專案:HelloWorld

HelloWorldProject.png

圖一、HelloWorld 專案在 Eclipse 當中的樣子

HelloWorldFiles.png

圖二、HelloWorld 專案在檔案總管中的樣子

檔案列表:HelloWorld 專案中的所有檔案列表

D:\android\HelloWorld>dir *.* /s /b
D:\android\HelloWorld\[file .classpath]]
D:\android\HelloWorld\.project
D:\android\HelloWorld\.settings
D:\android\HelloWorld\AndroidManifest.xml
D:\android\HelloWorld\assets
D:\android\HelloWorld\bin
D:\android\HelloWorld\default.properties
D:\android\HelloWorld\gen
D:\android\HelloWorld\res
D:\android\HelloWorld\src
D:\android\HelloWorld\.settings\org.eclipse.jdt.core.prefs
D:\android\HelloWorld\bin\ccc
D:\android\HelloWorld\bin\classes.dex
D:\android\HelloWorld\bin\HelloWorld.apk
D:\android\HelloWorld\bin\resources.ap_
D:\android\HelloWorld\bin\ccc\Hello
D:\android\HelloWorld\bin\ccc\Hello\HelloWorld.class
D:\android\HelloWorld\bin\ccc\Hello\R$attr.class
D:\android\HelloWorld\bin\ccc\Hello\R$drawable.class
D:\android\HelloWorld\bin\ccc\Hello\R$layout.class
D:\android\HelloWorld\bin\ccc\Hello\R$string.class
D:\android\HelloWorld\bin\ccc\Hello\R.class
D:\android\HelloWorld\gen\ccc
D:\android\HelloWorld\gen\ccc\Hello
D:\android\HelloWorld\gen\ccc\Hello\R.java
D:\android\HelloWorld\res\drawable-hdpi
D:\android\HelloWorld\res\drawable-ldpi
D:\android\HelloWorld\res\drawable-mdpi
D:\android\HelloWorld\res\layout
D:\android\HelloWorld\res\values
D:\android\HelloWorld\res\drawable-hdpi\icon.png
D:\android\HelloWorld\res\drawable-ldpi\icon.png
D:\android\HelloWorld\res\drawable-mdpi\icon.png
D:\android\HelloWorld\res\layout\main.xml
D:\android\HelloWorld\res\values\strings.xml
D:\android\HelloWorld\src\ccc
D:\android\HelloWorld\src\ccc\Hello
D:\android\HelloWorld\src\ccc\Hello\HelloWorld.java

檔案:HelloWorld/src/Hello.java

package ccc.Hello;
 
import android.app.Activity;
import android.os.Bundle;
 
public class HelloWorld extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

檔案:HelloWorld/gen/Hello.java

/* 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 ccc.Hello;
 
public final class R {
    public static final class attr {
    }
    public static final class drawable {
        public static final int icon=0x7f020000;
    }
    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;
    }
}

檔案:HelloWorld/res/layout/main.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>

檔案:HelloWorld/res/values/strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello">Hello World, Hello 你好!</string>
    <string name="app_name">HelloWorld</string>
</resources>

檔案:Android Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="ccc.Hello"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".HelloWorld"
                  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="8" />
 
</manifest>

檔案:default.properties

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
# 
# This file must be checked in Version Control Systems.
# 
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.

# Project target.
target=android-8

檔案:HelloWorld/.classpath

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="src" path="gen"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
    <classpathentry kind="output" path="bin"/>
</classpath>

檔案:HelloWorld/.project

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>HelloWorld</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>com.android.ide.eclipse.adt.ApkBuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>

檔案:HelloWorld/setting/org.eclipse.jdt.core.prefs

#Thu Sep 09 11:27:29 CST 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5

Facebook

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License