第一篇:Android 系统结构和SDK使用
第一章 Android系统介绍
1.1 系统介绍
有如下优点:
全开放智能手机平台
多硬件平台支持
使用众多标准技术
核心技术完整、统一
完善的SDK
完善的辅助文档
1.2 软件结构和使用的工具
分为4个层次:
1 JAVA应用层
2 Java框架
3 本地代码框架(c/c++)
4 linux系统及驱动
有很多辅助工具
aapt :Android Asset Packaging Tool 建立兼容包
adb : 调试桥
AIDL : 接口描述语言工具
AVDs : 虚拟设备
DDMS : 调试监视器服务
..... (略)
第二章 Android SDK的开发环境
第二篇 Android 应用程序的概述和框架
第3章 Android应用程序的开发方式
3.1 应用程序开发的结构
3.2 API参考文档的使用
第4章 Android 应用程序示例
4.1 HelloActivity程序的运行
4.2 HelloActivity的目录结构
HelloActivity
Android.mk 工程管理文件
AndroidManifest.xml 工程描述文件
\res
\layout
hello_activity.xml 布局文件
\values
string.xml 字符串文件
\src
\com
\example
\android
\helloactivity
HelloActivity.java
4.2.1 Android.mk
4.2.2 AndroidManifest.xml
内容如下:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.helloactivity"> //将从src目录开始的"com.example.android.helloactivity"搜索JAVA源代码
<application android:label="Hello,Activity!"> //表示应用程序,其包含了一个活动(Activity),也可以包含多个活动/组件
<activity android:name="HelloActivity" //Activity的名字,表示源码中的HelloActivity.java文件
android:lable="@string/lable_name" //Activity的标签,在res/string.xml中,缺省时使用<上一级的 android:label>
android:icon ="@drawable/icon_name" //Activity的图标,在res/drawable.xml中缺省时使用<application android:icon>
<intent-filter> //指定应用程序的启动方式
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter> //LAUNCHER:活动将在Android的桌面上出现。
</activity>
</application>
</manifest>
4.2.3 源码文件 HelloActivity.java
package com.example.android.helloactivity; // 定义包名
import android.app.Activity; // 引入包含的包
import android.os.Bundle;
public class HelloActivity extends Activity
{ public HelloActivity() { }
public void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState); // 重载 onCreate()方法
setContentView(R.layout.hello_activity); //指定使用res\layout\hello_activity.xml布局文件
}
}
4.2.4 hello_activity.xml 布局文件
<?xml version="1.0" encoding="utf-8"?>
<EditText //仅定义了此一个UI元素EditText
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="18sp"
android:autoText="true"
android:capitalize="sentences“
android:text="@string/hello_activity_text" //初始文本是string.xml中的hello_activity_text
/>
4.2.5 其他资源文件
string.xml //此只是资源文件中的一个,还有的话也放到此目录即可
<?xml version="1.0" encoding="utf-8"?>
<resources> //供其他文件使用的符号内容如下:
<string name="hello_activity_text_">Hello,World!</string>
<string name="lable_name">myActivity</string> //
</resources>
4.3 HelloActivity的编译结构