GUI创建套件Widget的使用-实验报告.docx

上传人:wj 文档编号:346940 上传时间:2023-04-29 格式:DOCX 页数:30 大小:846.45KB
下载 相关 举报
GUI创建套件Widget的使用-实验报告.docx_第1页
第1页 / 共30页
GUI创建套件Widget的使用-实验报告.docx_第2页
第2页 / 共30页
GUI创建套件Widget的使用-实验报告.docx_第3页
第3页 / 共30页
GUI创建套件Widget的使用-实验报告.docx_第4页
第4页 / 共30页
GUI创建套件Widget的使用-实验报告.docx_第5页
第5页 / 共30页
GUI创建套件Widget的使用-实验报告.docx_第6页
第6页 / 共30页
GUI创建套件Widget的使用-实验报告.docx_第7页
第7页 / 共30页
GUI创建套件Widget的使用-实验报告.docx_第8页
第8页 / 共30页
GUI创建套件Widget的使用-实验报告.docx_第9页
第9页 / 共30页
GUI创建套件Widget的使用-实验报告.docx_第10页
第10页 / 共30页
GUI创建套件Widget的使用-实验报告.docx_第11页
第11页 / 共30页
GUI创建套件Widget的使用-实验报告.docx_第12页
第12页 / 共30页
GUI创建套件Widget的使用-实验报告.docx_第13页
第13页 / 共30页
GUI创建套件Widget的使用-实验报告.docx_第14页
第14页 / 共30页
GUI创建套件Widget的使用-实验报告.docx_第15页
第15页 / 共30页
GUI创建套件Widget的使用-实验报告.docx_第16页
第16页 / 共30页
GUI创建套件Widget的使用-实验报告.docx_第17页
第17页 / 共30页
GUI创建套件Widget的使用-实验报告.docx_第18页
第18页 / 共30页
GUI创建套件Widget的使用-实验报告.docx_第19页
第19页 / 共30页
GUI创建套件Widget的使用-实验报告.docx_第20页
第20页 / 共30页
亲,该文档总共30页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

GUI创建套件Widget的使用-实验报告.docx

《GUI创建套件Widget的使用-实验报告.docx》由会员分享,可在线阅读,更多相关《GUI创建套件Widget的使用-实验报告.docx(30页珍藏版)》请在冰点文库上搜索。

GUI创建套件Widget的使用-实验报告.docx

实验二 GUI创建套件Widget的使用

目录

1实验目的及要求 1

2实验设备(环境)及要求 1

3实验内容 1

4实验步骤 2

5实验核心代码(关键代码),及调试中的问题 2

线性布局:

(计算器界面) 2

表格布局:

7

相对布局:

9

单选框,复选框以及消息对话框 12

自定义对话框代码 14

下拉列表的使用 17

时间日期的使用 19

日期控件使用 19

时间控件的使用 21

6实验的运行结果及分析 24

线性布局结果:

24

表格布局结果:

24

相对布局结果:

25

单选框复选框以及消息对话框:

25

自定义对话框:

26

下拉列表的结果:

27

日期控件的结果:

27

时间控件的结果:

28

7实验总结心得体会 29

1实验目的及要求

1.掌握资源编辑器、布局编辑器的使用

2.掌握按钮、编辑框、日期时间、对话框、下拉列表等主要

widget组件编程

2实验设备(环境)及要求

1)PC计算机

2)JDK安装包

3)Eclipse安装包

4)AndroidSDK安装包

5)ADT插件

3实验内容

1.编程练习垂直线性布局、水平线性布局、相对布局、表单布局界面布局方法。

2.设计按钮、复选框、单选按钮、普通按钮、单机按钮弹出对话框。

4实验步骤

1.新建项目Button/Edit,在res/layput中修改布局文件

main.xml

2.编辑Activity程序文件ButtonActivity

3.继承Dialog类,新建自定义的对话框类

DialogPro.java

5实验核心代码(关键代码),及调试中的问题

线性布局:

(计算器界面)

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

>

android=""

android:

layout_width="match_parent"android:

layout_height="match_parent"android:

background="#ffffff"android:

orientation="vertical">

--尽量不要使用多层嵌套,会影响运行速度-->

layout_width="fill_parent"android:

layout_height="wrap_content"android:

orientation="horizontal">

android:

id="@+id/msg"android:

layout_width="fill_parent"

android:

layout_height="wrap_content"/>

--布局嵌套布局-->

layout_width="fill_parent"android:

layout_height="wrap_content"android:

orientation="horizontal">

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="1"android:

text="mc"/>

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="1"android:

text="m+"/>

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="1"android:

text="m-"/>

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="1"android:

text="mr"/>

layout_width="fill_parent"android:

layout_height="wrap_content"android:

orientation="horizontal">

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="1"android:

text="C"/>

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="1"android:

text="+/-"/>

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="1"android:

text="/"/>

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="1"android:

text="*"/>

layout_width="fill_parent"android:

layout_height="wrap_content"android:

orientation="horizontal">

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="1"android:

text="7"/>

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="1"android:

text="8"/>

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="1"android:

text="9"/>

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="1"android:

text="-"/>

layout_width="fill_parent"android:

layout_height="wrap_content"android:

orientation="horizontal">

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="1"android:

text="4"/>

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="1"android:

text="5"/>

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="1"android:

text="6"/>

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="1"android:

text="+"/>

layout_width="fill_parent"android:

layout_height="wrap_content"android:

orientation="horizontal"

>

layout_width="wrap_content"

android:

layout_height="wrap_content"android:

layout_weight="3"android:

orientation="vertical">

layout_width="fill_parent"android:

layout_height="wrap_content"android:

orientation="horizontal">

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="1"android:

text="1"/>

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="1"android:

text="2"

android:

background="@drawable/rectborder"/>

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="1"android:

text="3"/>

layout_width="fill_parent"android:

layout_height="wrap_content"android:

orientation="horizontal">

android:

layout_width="0dp"android:

layout_height="wrap_content"android:

layout_weight="2"android:

text="0"/>

android:

layout_width="0dp"android:

layout_height="wrap_content"

android:

layout_weight="1"android:

text="."/>

layout_width="wrap_content"android:

layout_height="fill_parent"android:

layout_weight="1"android:

orientation="horizontal">

android:

layout_width="fill_parent"android:

layout_height="fill_parent"android:

text="="/>

表格布局:

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

>

android=""

android:

layout_width="match_parent"android:

layout_height="match_parent"android:

orientation="vertical">

--stretchColumns拉伸适应填充窗口是从0开始标记的,也就是0表示只有1列

shrinkable 收缩适应填充窗口-->

id="@+id/table1"

android:

layout_width="fill_parent"android:

layout_height="wrap_content"android:

stretchColumns="0">

android:

id="@+id/tablerow1"android:

layout_width="fill_parent"android:

layout_height="wrap_content">

android:

layout_width="fill_parent"android:

layout_height="wrap_content"android:

gravity="center"android:

padding="4dp"

android:

text="表格布局"

android:

textSize="20dp"/>

id="@+id/table2"

android:

layout_width="fill_parent"android:

layout_height="wrap_content"android:

shrinkColumns="0,1,2,3">

android:

id="@+id/tablerow2"android:

layout_width="fill_parent"android:

layout_height="wrap_content">

android:

id="@+id/btn1"android:

layout_width="wrap_content"android:

layout_height="wrap_content"android:

text="button1"/>

android:

id="@+id/btn2"android:

layout_width="wrap_content"android:

layout_height="wrap_content"android:

text="button2"/>

android:

id="@+id/btn3"android:

layout_width="wrap_content"android:

layout_height="wrap_content"android:

text="button3"/>

android:

id="@+id/btn4"

android:

layout_width="wrap_content"android:

layout_height="wrap_content"android:

text="button4"/>

id="@+id/table3"

android:

layout_width="fill_parent"android:

layout_height="wrap_content"android:

stretchColumns="0">

android:

id="@+id/tablerow3"android:

layout_width="fill_parent"android:

layout_height="wrap_content">

android:

layout_width="fill_parent"android:

layout_height="wrap_content"

android:

text="查询"

/>

相对布局:

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

>

android=""

android:

layout_width="match_parent"android:

layout_height="match_parent">

---控件的大小会相对于相对的控件大小而改变-->

android:

id="@+id/center"android:

layout_width="120dp"android:

layout_height="wrap_content"android:

layout_centerInParent="true"

android:

text="中间"/>

android:

id="@+id/above"android:

layout_width="wrap_content"android:

layout_height="wrap_content"android:

layout_above="@id/center"android:

layout_alignLeft="@id/center"android:

layout_alignRight="@id/center"android:

layout_alignParentTop="false"

android:

text="上面"/>

android:

id="@+id/below"android:

layout_width="wrap_content"android:

layout_height="wrap_content"android:

layout_alignLeft="@id/center"android:

layout_alignRight="@id/center"android:

layout_below="@id/center"

android:

text="下面"/>

--

先是相对于左边,layout_toLeftof 然后再上对齐,下对齐

android:

layout_alignTop="@id/center"android:

layout_alignBottom="@id/center"

-->

android:

id="@+id/left"android:

layout_width="wrap_content"android:

layout_height="wrap_content"android:

layout_alignBottom="@id/center"android:

layout_alignParentLeft="true"android:

layout_alignTop="@id/center"android:

layout_toLeftOf="@id/center"

android:

text="左边"/>

---使其充满左边的空白地方android:

layout_alignParentLeft="true"-->

android:

id="@+id/right"android:

layout_width="wrap_content"android:

layout_height="wrap_content"android:

layout_alignBottom="@id/center"android:

layout_alignParentRight="true"android:

layout_alignTop="@id/center"

android:

layout_toRightOf="@id/center"

android:

text="右边"/>

android:

id="@+id/top_left_corner"android:

layout_width="wrap_content"android:

layout_height="wrap_content"android:

layout_above="@id/center"android:

layout_alignParentLeft="true"android:

layout_toLeftOf="@id/center"

android:

text="左上角"/>

android:

id="@+id/top_right_corner"android:

layout_width="wrap_content"android:

layout_height="wrap_content"android:

layout_above="@id/center"android:

layout_alignParentRight="true"android:

layout_toRightOf="@id/center"

android:

text="右上角"/>

android:

id="@+id/lower_left_quarter"android:

layout_width="wrap_content"android:

layout_height="wrap_content"android:

layout_toLeftOf="@id/center"android:

layout_below="@id/center"android:

layout_alignParentLeft="true"

android:

text="左下角"/>

android:

id="@+id/lower_right_quarter"android:

layout_width="wrap_content"android:

layout_height="wrap_co

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

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2