南昌航空大学android实验报告二.doc
《南昌航空大学android实验报告二.doc》由会员分享,可在线阅读,更多相关《南昌航空大学android实验报告二.doc(11页珍藏版)》请在冰豆网上搜索。
南昌航空大学实验报告
二0一二年十二月九日
课程名称:
移动终端编程技术实验名称:
Android用户界面编程
班级:
10201404姓名:
金林成宇同组人:
指导教师评定:
签名:
一、实验目的
了解Android编程原理,熟练掌握界面控件的使用;
熟练应用各种界面布局;掌握界面控件设计;掌握控件的事件处理编程
二、实验工具
Eclipse(MyEclipse)+ADT+Android2.2SDK;
三、实验题目
1.使用XML创建布局,设计一个登录界面;效果如图所示:
图1登录界面效果图
2.参考下图中界面控件的摆放位置,分别使用线性布局、相对布局和绝对布局实现用户界面,并对比各种布局实现的复杂程度和对不同屏幕尺寸的适应能力。
图2效果图
3.ListView的使用
图3初始界面图4点击一项后的界面
四、实验步骤
1.代码如下:
Main.xml
xmlversion="1.0"encoding="utf-8"?
>
android="
android:
layout_width="fill_parent"
android:
layout_height="fill_parent"
android:
orientation="vertical">
android:
layout_width="fill_parent"
android:
layout_height="wrap_content"
android:
orientation="horizontal">
android:
id="@+id/UserText"
android:
layout_width="wrap_content"
android:
layout_height="wrap_content"
android:
text="@string/User"/>
android:
id="@+id/User"
android:
layout_width="fill_parent"
android:
layout_height="wrap_content"/>
android:
layout_width="fill_parent"
android:
layout_height="wrap_content"
android:
orientation="horizontal">
android:
id="@+id/PasswordText"
android:
layout_width="wrap_content"
android:
layout_height="wrap_content"
android:
text="@string/Password"/>
android:
id="@+id/Pssword"
android:
layout_width="fill_parent"
android:
layout_height="wrap_content"
android:
password="true"/>
android:
layout_width="fill_parent"
android:
layout_height="wrap_content"
android:
orientation="horizontal">
android:
id="@+id/CheckBox"
android:
layout_width="wrap_content"
android:
layout_height="wrap_content"
android:
text="@string/CheckBox"/>
2.自做;
线性布局
xmlversion="1.0"encoding="utf-8"?
>
android="
android:
orientation="vertical"
android:
layout_width="fill_parent"
android:
layout_height="fill_parent"
>
android:
layout_width="fill_parent"
android:
layout_height="wrap_content"
android:
orientation="horizontal">
android:
id="@+id/NameText"
android:
layout_width="wrap_content"
android:
layout_height="wrap_content"
android:
text="姓名:
"/>
android:
id="@+id/Name"
android:
layout_width="fill_parent"
android:
layout_height="wrap_content"
android:
text="king"/>
android:
layout_width="fill_parent"
android:
layout_height="wrap_content"
android:
orientation="horizontal">
android:
id="@+id/AgeText"
android:
layout_width="wrap_content"
android:
layout_height="wrap_content"
android:
text="年龄:
"/>
android:
id="@+id/UserText"
android:
layout_width="fill_parent"
android:
layout_height="wrap_content"
android:
text="30"/>
android:
layout_width="fill_parent"
android:
layout_height="wrap_content"
android:
orientation="horizontal">
android:
id="@+id/HeightText"
android:
layout_width="wrap_content"
android:
layout_height="wrap_content"
android:
text="身高:
"/>
android:
id="@+id/Height"
android:
layout_width="fill_parent"
android:
layout_height="wrap_content"
android:
text="1.75"/>
android:
layout_width="fill_parent"
android:
layout_height="wrap_content"
android:
orientation="horizontal">