安卓课程设计
学生姓名:
学 号:
专 业: )
班 级:14-1
设计题目: 简易计算器
学年学期: 20## -2016 学年第一学期
指导教师:
签名: 日期:
目录
第1章 安卓应用程序开发背景....................................................... 2
§1.1开发背景............................................................................... 2
§1.2开发环境............................................................................... 3
第2章 安卓应用程序开发理论与方法............................................ 3
第3章 “计算器”应用程序的设计与实现.................................... 5
§3.1 拟解决的问题及目标......................................................... 5
§3.2 总体设计............................................................................ 6
§3.3 详细设计与编码实现......................................................... 6
第4章 总结................................................................................... 15
1.课程设计的目的 Java语言是当今流行的网络编程语言,它具有面向对象、跨平台、分布应用等特点。面向对象的开发方法是当今世界最流行的开发方法,它不仅具有更贴近自然的语义,而且有利于软件的维护和继承。 为了进一步巩固课堂上所学到的知识,深刻把握Java语言的重要概念及其面向对象的特性,使我们能够熟练的应用面向对象的思想和设计方法解决实际问题的能力。 通过此次课程设计,巩固所学Java语言基本知识,增进Java语言编辑基本功,掌握JDK、Editplus、Eclipse、JCreator等开发工具的运用,拓宽常用类库的应用。使学生通过该教学环节与手段,把所学课程及相关知识加以融会贯通,全面掌握Java语言的编程思想及面向对象程序设计的方法,为今后从事实际工作打下坚实的基础。
Eclipse 是一个开放源代码的、基于Java的可扩展开发平台。就其本身而言, 它只是一个框架和一组服务,用于通过插件组件构建开发环境。幸运的是,Eclipse 附带了一个标准的插件集,包括Java开发工具(Java Development Kit,JDK)。 虽然大多数用户很乐于将 Eclipse 当作 Java 集成开发环境(IDE)来使用,但 Eclipse 的目标却不仅限于此。Eclipse 还包括插件开发环境(Plug-in Development Environment,PDE),这个组件主要针对希望扩展 Eclipse 的软件开发人员,因为它允许他们构建与 Eclipse 环境无缝集成的工具。由于 Eclipse 中的每样东西都是插件,对于给 Eclipse 提供插件,以及给用户提供一致和统一的集成开发环境而言,所有工具开发人员都具有同等的发挥场所。 这种平等和一致性并不仅限于 Java 开发工具。尽管 Eclipse 是使用 Java 语言开发的,但它的用途并不限于 Java 语言;例如,支持诸如 C/C++ 和 COBOL 等编程语言的插件已经可用,或预计将会推出。Eclipse 框架还可用来作为与软件开发无关的其他应用程序类型的基础,比如内容管理系统。 基于 Eclipse 的应用程序的一个突出例子是 IBM Rational Software Architect,它构成了 IBM Java 开发工具系列的基础
总体设计
1、系统的软件结构图
新建一个Application Project,在layout下的main.xml文件中布局,我采用的是Linearlayout布局,向空白的界面,拖22个buton控件和两个TextVeiw控件,并修改id和name。效果如图
二.功能的实现
这个简单的计算器能够完成加,减。乘,除,开平方,平方,保存结果和删除数据操作。
三.运行结果
Main.xml代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget32"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical" >
<Button
android:textColor="@color/DarkSlateBlue"
android:id="@+id/key_equal"
android:layout_width="@dimen/width"
android:layout_height="@dimen/maxheight"
android:layout_toRightOf="@+id/key_plus"
android:layout_alignTop="@+id/key_dash"
android:onClick="myClick"
android:text="@string/key_equal"
android:textSize="@dimen/size" />
<Button
android:textColor="@color/gray"
android:id="@+id/key_plus"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_alignLeft="@+id/key_dash"
android:layout_alignTop="@+id/key_0"
android:onClick="myClick"
android:text="@string/key_plus"
android:textSize="@dimen/size" />
<Button
android:id="@+id/key_0"
android:layout_width="@dimen/maxwidth"
android:layout_height="@dimen/height"
android:layout_alignLeft="@+id/key_2"
android:layout_alignTop="@+id/key_period"
android:onClick="myClick"
android:text="@string/key_0"
android:textSize="@dimen/size" />
<Button
android:id="@+id/key_period"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_below="@+id/key_dash"
android:layout_toLeftOf="@+id/key_2"
android:onClick="myClick"
android:text="@string/key_period"
android:textSize="@dimen/size" />
<Button
android:textColor="@color/gray"
android:id="@+id/key_dash"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_alignLeft="@+id/key_star"
android:layout_alignTop="@+id/key_3"
android:onClick="myClick"
android:text="@string/key_dash"
android:textSize="@dimen/size" />
<Button
android:id="@+id/key_3"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_alignLeft="@+id/key_6"
android:layout_alignTop="@+id/key_2"
android:onClick="myClick"
android:text="@string/key_3"
android:textSize="@dimen/size" />
<Button
android:id="@+id/key_2"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_alignLeft="@+id/key_5"
android:layout_alignTop="@+id/key_1"
android:onClick="myClick"
android:text="@string/key_2"
android:textSize="@dimen/size" />
<Button
android:id="@+id/key_1"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_below="@+id/key_star"
android:layout_toLeftOf="@+id/key_5"
android:onClick="myClick"
android:text="@string/key_1"
android:textSize="@dimen/size" />
<Button
android:textColor="@color/DarkSlateBlue"
android:id="@+id/key_sqrt"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_toRightOf="@+id/key_star"
android:layout_alignTop="@+id/key_star"
android:onClick="myClick"
android:text="@string/key_sqrt"
android:textSize="@dimen/minsize" />
<Button
android:textColor="@color/gray"
android:id="@+id/key_star"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_alignLeft="@+id/key_slash"
android:layout_alignTop="@+id/key_4"
android:onClick="myClick"
android:text="@string/key_star"
android:textSize="@dimen/size" />
<Button
android:id="@+id/key_6"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_alignLeft="@+id/key_9"
android:layout_alignTop="@+id/key_4"
android:onClick="myClick"
android:text="@string/key_6"
android:textSize="@dimen/size" />
<Button
android:id="@+id/key_5"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_alignLeft="@+id/key_8"
android:layout_alignTop="@+id/key_4"
android:onClick="myClick"
android:text="@string/key_5"
android:textSize="@dimen/size" />
<Button
android:id="@+id/key_4"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_below="@+id/key_slash"
android:layout_toLeftOf="@+id/key_8"
android:onClick="myClick"
android:text="@string/key_4"
android:textSize="@dimen/size" />
<Button
android:textColor="@color/DarkSlateBlue"
android:id="@+id/key_square"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_toRightOf="@+id/key_slash"
android:layout_alignTop="@+id/key_slash"
android:onClick="myClick"
android:text="@string/key_square"
android:textSize="@dimen/size" />
<Button
android:textColor="@color/gray"
android:id="@+id/key_slash"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_alignTop="@+id/key_9"
android:layout_toRightOf="@+id/key_9"
android:onClick="myClick"
android:text="@string/key_slash"
android:textSize="@dimen/size" />
<Button
android:id="@+id/key_9"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_alignTop="@+id/key_8"
android:layout_toRightOf="@+id/key_8"
android:onClick="myClick"
android:text="@string/key_9"
android:textSize="@dimen/size" />
<Button
android:id="@+id/key_8"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_alignTop="@+id/key_7"
android:layout_toRightOf="@+id/key_7"
android:onClick="myClick"
android:text="@string/key_8"
android:textSize="@dimen/size" />
<Button
android:id="@+id/key_7"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_alignParentLeft="true"
android:layout_below="@+id/key_c"
android:onClick="myClick"
android:text="@string/key_7"
android:textSize="@dimen/size" />
<Button
android:textColor="@color/DarkSlateBlue"
android:id="@+id/key_pn"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_toRightOf="@+id/key_exp"
android:layout_alignTop="@+id/key_exp"
android:onClick="myClick"
android:text="@string/key_pn"
android:textSize="@dimen/size" />
<Button
android:textColor="@color/DarkSlateBlue"
android:id="@+id/key_exp"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_toRightOf="@+id/key_left"
android:layout_alignTop="@+id/key_left"
android:onClick="myClick"
android:text="@string/key_exp"
android:textSize="@dimen/minsize" />
<Button
android:textColor="@color/tomato"
android:id="@+id/key_left"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_toRightOf="@+id/key_c"
android:layout_alignTop="@+id/key_c"
android:onClick="myClick"
android:text="@string/key_left"
android:textSize="@dimen/size" />
<Button
android:textColor="@color/tomato"
android:id="@+id/key_c"
android:layout_width="@dimen/maxwidth"
android:layout_height="@dimen/height"
android:layout_alignParentLeft="true"
android:layout_below="@+id/key_mrc"
android:onClick="myClick"
android:text="@string/key_c"
android:textSize="@dimen/size" />
<Button
android:textColor="@color/DeepSkyBlue"
android:id="@+id/key_mdash"
android:layout_width="@dimen/maxwidth"
android:layout_height="@dimen/height"
android:layout_toRightOf="@+id/key_madd"
android:layout_alignTop="@+id/key_mrc"
android:onClick="myClick"
android:text="@string/key_mdash"
android:textSize="@dimen/size" />
<Button
android:textColor="@color/DeepSkyBlue"
android:id="@+id/key_madd"
android:layout_width="@dimen/maxwidth"
android:layout_height="@dimen/height"
android:layout_toRightOf="@+id/key_mrc"
android:layout_alignTop="@+id/key_mrc"
android:onClick="myClick"
android:text="@string/key_madd"
android:textSize="@dimen/size" />
<Button
android:textColor="@color/DeepSkyBlue"
android:id="@+id/key_mrc"
android:enabled="false"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_alignParentLeft="true"
android:layout_below="@+id/edittext"
android:onClick="myClick"
android:text="@string/key_mrc"
android:textSize="@dimen/minsize" />
<!--
edittext
gravity文本显示方向
-->
<EditText
android:id="@+id/edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:bufferType="editable"
android:editable="true"
android:ellipsize="none"
android:maxLength="20"
android:scrollbars="horizontal"
android:singleLine="true"
android:text=""
android:textSize="60sp" />
</RelativeLayout>
计算 2*9
三.实验总结
通过这段时间制作计算器app,我学到了非常多的andrio专业知识,体会了其中的乐趣,当我自己解决问题,运行成功时,那种成就感,非常的好。我对andrio充满了兴趣。
开发期间,我学会了有目的的去学习一些将要用到的东西,仔细地考虑工作流程的规律和步骤,充分利用手中的开发工具,利用其所具备的功能,尽量使自己的开发在代码上实现少而精确、让用户能够尽量简单地进行操作。但是在检测过程中,还是出现了很多的不足之处,这些都是要在今后的工作中需要努力改进和完善的。