南昌航空大学android实验报告二.docx

上传人:b****8 文档编号:9256586 上传时间:2023-02-03 格式:DOCX 页数:18 大小:58.66KB
下载 相关 举报
南昌航空大学android实验报告二.docx_第1页
第1页 / 共18页
南昌航空大学android实验报告二.docx_第2页
第2页 / 共18页
南昌航空大学android实验报告二.docx_第3页
第3页 / 共18页
南昌航空大学android实验报告二.docx_第4页
第4页 / 共18页
南昌航空大学android实验报告二.docx_第5页
第5页 / 共18页
点击查看更多>>
下载资源
资源描述

南昌航空大学android实验报告二.docx

《南昌航空大学android实验报告二.docx》由会员分享,可在线阅读,更多相关《南昌航空大学android实验报告二.docx(18页珍藏版)》请在冰豆网上搜索。

南昌航空大学android实验报告二.docx

南昌航空大学android实验报告二

南昌航空大学实验报告

二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"/>

android:

id="@+id/Submit"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_marginLeft="100dip"

android:

text="@string/Submit"/>

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">

android:

id="@+id/Button1"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

text="添加数据"/>

android:

id="@+id/Button2"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

text="全部显示"/>

android:

id="@+id/Button3"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

text="清除显示"/>

android:

id="@+id/Button4"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

text="全部删除"/>

相对布局

xmlversion="1.0"encoding="utf-8"?

>

android="

android:

layout_width="fill_parent"

android:

layout_height="fill_parent"

>

android:

id="@+id/NameText"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

text="姓名:

"

android:

layout_marginTop="10dip"/>

android:

id="@+id/Name"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

layout_toRightOf="@id/NameText"

android:

text="king"/>

android:

id="@+id/AgeText"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

text="年龄:

"

android:

layout_marginTop="30dip"

android:

layout_below="@id/NameText"/>

android:

id="@+id/Age"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

layout_below="@id/Name"

android:

layout_toRightOf="@id/AgeText"

android:

text="30"/>

android:

id="@+id/HeightText"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

text="身高:

"

android:

layout_marginTop="30dip"

android:

layout_below="@id/AgeText"/>

android:

id="@+id/Height"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

layout_below="@id/Age"

android:

layout_toRightOf="@id/HeightText"

android:

text="1.75"/>

android:

id="@+id/Button1"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_below="@id/Height"

android:

text="添加数据"/>

android:

id="@+id/Button2"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_toRightOf="@id/Button1"

android:

layout_below="@id/Height"

android:

text="全部显示"/>

android:

id="@+id/Button3"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_toRightOf="@id/Button2"

android:

layout_below="@id/Height"

android:

text="清除显示"/>

android:

id="@+id/Button4"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_toRightOf="@id/Button3"

android:

layout_below="@id/Height"

android:

text="全部删除"/>

绝对布局

xmlversion="1.0"encoding="utf-8"?

>

android="

android:

layout_width="fill_parent"

android:

layout_height="fill_parent"

>

android:

id="@+id/NameText"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

text="姓名:

"

android:

layout_y="10dip"/>

android:

id="@+id/Name"

android:

layout_width="280dip"

android:

layout_height="50dip"

android:

layout_x="40dip"

android:

text="king"/>

android:

id="@+id/AgeText"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

text="年龄:

"

android:

layout_y="60dip"/>

android:

id="@+id/Age"

android:

layout_width="280dip"

android:

layout_height="50dip"

android:

layout_x="40dip"

android:

layout_y="50dip"

android:

text="30"/>

android:

id="@+id/HeightText"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

text="身高:

"

android:

layout_y="110dip"/>

android:

id="@+id/Height"

android:

layout_width="280dip"

android:

layout_height="50dip"

android:

layout_x="40dip"

android:

layout_y="100dip"

android:

text="1.75"/>

android:

id="@+id/Button1"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_y="160dip"

android:

text="添加数据"/>

android:

id="@+id/Button2"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_x="80dip"

android:

layout_y="160dip"

android:

text="全部显示"/>

android:

id="@+id/Button3"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_x="160dip"

android:

layout_y="160dip"

android:

text="清除显示"/>

android:

id="@+id/Button4"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_x="240dip"

android:

layout_y="160dip"

android:

text="全部删除"/>

3.参考代码:

(1)main.xml:

xmlversion="1.0"encoding="utf-8"?

>

android="

android:

orientation="vertical"

android:

layout_width="fill_parent"

android:

layout_height="fill_parent"

>

id="@+id/TextView01"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

text="@string/hello"/>

id="@+id/ListView01"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content">

(2)ListViewDemo.java

importjava.util.ArrayList;

importjava.util.List;

importandroid.app.Activity;

importandroid.os.Bundle;

importandroid.view.View;

importandroid.widget.AdapterView;

importandroid.widget.ArrayAdapter;

importandroid.widget.ListView;

importandroid.widget.TextView;

publicclassListViewDemoextendsActivity{

/**Calledwhentheactivityisfirstcreated.*/

@Override

publicvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 幼儿教育 > 幼儿读物

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1