android新手入门内部培训教程.docx
《android新手入门内部培训教程.docx》由会员分享,可在线阅读,更多相关《android新手入门内部培训教程.docx(17页珍藏版)》请在冰豆网上搜索。
android新手入门内部培训教程
一、目录
一、目录开发搭建环境1
开发搭建环境1
1、javasdk1
2、Eclipse2
3、androidSDK插件;SVN版本控制插件2
二、文件结构3
1.新建工程3
2.输入新建工程内容3
3.工程目录结构4
三、XML布局和国际化5
1.常用的布局5
1.绝对布局AbsoluteLayout5
2.线性布局6
3.表格布局TableLayout6
2.最常用的LinearLayout介绍8
3.国际化9
四、按钮事件和Intent传值10
1、概要10
1、用例图10
2、时序图11
2、效果11
1.程序进入后的界面:
11
2.点击按钮后12
3.输入文字,并点击图片按钮后12
4.设置中文后12
3、代码13
1.Main.java13
2.GetIntent.java14
3.配置文件15
五、Activity生命周期15
六、其他内容16
开发搭建环境
1、javasdk
jdk1.6
2、Eclipse
Eclipse下载地址
3、androidSDK插件;SVN版本控制插件
1、启动Eclipse点击标题栏上的Help,选择InstallNewSoftware选项,如图:
2、点击ADD按钮,并输入要安装的插件地址
SDK:
SVN:
二、文件结构
1.新建工程
点击File,New选项,点击AndroidProject;或者
点击File,New选项,点击Other,如下图:
2.输入新建工程内容:
3.工程目录结构
三、XML布局和国际化
1.常用的布局
1.绝对布局AbsoluteLayout
xmlversion="1.0"encoding="utf-8"?
>
android:
id="@+id/widget0"
android:
layout_width="fill_parent"
android:
layout_height="fill_parent"
xmlns:
android="
>
效果:
2.线性布局
下面会详细介绍到
3.表格布局TableLayout
xmlversion="1.0"encoding="utf-8"?
>
android:
id="@+id/widget31"
android:
layout_width="fill_parent"
android:
layout_height="fill_parent"
android:
orientation="vertical"
xmlns:
android="
>
android:
id="@+id/widget32"
android:
layout_width="fill_parent"
android:
layout_height="wrap_content"
android:
orientation="horizontal"
>
android:
id="@+id/widget33"
android:
layout_width="fill_parent"
android:
layout_height="wrap_content"
android:
orientation="horizontal"
>
android:
id="@+id/widget34"
android:
layout_width="fill_parent"
android:
layout_height="wrap_content"
android:
orientation="horizontal"
>
2.最常用的LinearLayout介绍
xmlversion="1.0"encoding="utf-8"?
>
android="
android:
orientation="vertical"android:
layout_width="fill_parent"
android:
layout_height="fill_parent">
layout_width="fill_parent"
android:
layout_height="wrap_content"android:
text="@string/hello"
android:
id="@+id/tv"/>
text="@string/change_title"android:
id="@+id/bt"
android:
layout_width="wrap_content"android:
layout_height="wrap_content"/>
src="@drawable/change"android:
id="@+id/ib"
android:
visibility="gone"android:
layout_width="wrap_content"
android:
layout_height="wrap_content"/>
text="@string/input"android:
id="@+id/et"
android:
layout_width="fill_parent"android:
layout_height="wrap_content"
android:
singleLine="true"/>
3.国际化
1.文件结构,目前只有默认的(英文),和中文简体
2.英文
xmlversion="1.0"encoding="utf-8"?
>
HelloWorld!
clickbuttonchangetitle.
HelloWorld!
~
ChangeTitle
inputsomethingtointent
yourinputisempty!
~
3.中文
xmlversion="1.0"encoding="utf-8"?
>
你好,世界!
点击按钮更换标题。
你好,世界!
~
换标题
输入点什么传过去
你输入的值是空!
~
四、按钮事件和Intent传值
1、概要
1、用例图
2、时序图
2、效果
1.程序进入后的界面:
2.点击按钮后
3.输入文字,并点击图片按钮后
4.设置中文后
3、代码
1.Main.java
packagecom.skyworth.helloword;
importandroid.app.Activity;
importandroid.content.Intent;
importandroid.os.Bundle;
importandroid.view.View;
importandroid.view.View.OnClickListener;
importandroid.widget.EditText;
importandroid.widget.TextView;
publicclassMainextendsActivity{
/**Calledwhentheactivit