07081方明星 计算器设计报告.docx

上传人:b****4 文档编号:11535256 上传时间:2023-03-19 格式:DOCX 页数:21 大小:71.97KB
下载 相关 举报
07081方明星 计算器设计报告.docx_第1页
第1页 / 共21页
07081方明星 计算器设计报告.docx_第2页
第2页 / 共21页
07081方明星 计算器设计报告.docx_第3页
第3页 / 共21页
07081方明星 计算器设计报告.docx_第4页
第4页 / 共21页
07081方明星 计算器设计报告.docx_第5页
第5页 / 共21页
点击查看更多>>
下载资源
资源描述

07081方明星 计算器设计报告.docx

《07081方明星 计算器设计报告.docx》由会员分享,可在线阅读,更多相关《07081方明星 计算器设计报告.docx(21页珍藏版)》请在冰豆网上搜索。

07081方明星 计算器设计报告.docx

07081方明星计算器设计报告

 

APP设计报告

——计算器

 

姓名:

方明星

学号:

070812052

2015年6月

APP设计报告书

——计算器

1、App简介

简单设计一个计算器,实现其可以加、减、乘、除、开方、幂、sin、cos简单的功能。

2、App的开发环境

在Jdk5.0的基础下安装android4.0.3。

3、App设计介绍

运用已学的知识写一个简单的APP,计算器的功能可以很简单也可以很复杂,我就简单的写了一些功能,仅能实现计算器的加、减、乘、除、开方、幂、sin、cos以及数的正负功能,对于简单的计算还是可以进行的。

四、App设计简介

整个App涉及到两个布局,一个是显示数据的文本框,另一个则是按键部分,对于文本框,则要实现它的可写性,对于按键则要设置事件监听器,以便实现其功能。

1、初始界面

新建一个名为“JiSuanQi”的Android项目,在新建项目的res\layout目录下的main.xml布局文件中,添加一个GridLayout布局管理器,设置计算器的界面。

点击不同的按钮就会实现不同的功能。

具体代码如下:

(1)main.xml

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

>

android="

xmlns:

tools="

android:

id="@+id/LayoutMain"

android:

layout_width="fill_parent"

android:

layout_height="fill_parent"

android:

orientation="vertical">

android:

id="@+id/text"

android:

layout_width="fill_parent"

android:

layout_height="60dp"

android:

layout_weight="1"

android:

ems="10"

android:

inputType="none">

android:

id="@+id/LayoutButtons1"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

layout_weight="1"

android:

orientation="horizontal">

android:

id="@+id/btu1"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="^"/>

android:

id="@+id/btu2"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="√"/>

android:

id="@+id/btu3"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="sin"/>

android:

id="@+id/btu4"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="cos"/>

android:

id="@+id/LayoutButtons1"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

layout_weight="1"

android:

orientation="horizontal">

android:

id="@+id/btu5"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="C"/>

android:

id="@+id/btu6"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="+/-"/>

android:

id="@+id/btu7"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="S"/>

android:

id="@+id/btu8"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="/"/>

android:

id="@+id/LayoutButtons2"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

layout_weight="1"

android:

orientation="horizontal">

android:

id="@+id/btu9"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="7"/>

android:

id="@+id/btu10"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="8"/>

android:

id="@+id/btu11"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="9"/>

android:

id="@+id/btu12"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="*"/>

android:

id="@+id/LayoutButtons3"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

layout_weight="1"

android:

orientation="horizontal">

android:

id="@+id/btu13"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="4"/>

android:

id="@+id/btu14"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="5"/>

android:

id="@+id/btu15"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="6"/>

android:

id="@+id/btu16"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="-"/>

android:

id="@+id/LayoutButtons4"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

layout_weight="2"

android:

orientation="horizontal">

android:

id="@+id/btu17"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="1"/>

android:

id="@+id/btu18"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="2"/>

android:

id="@+id/btu19"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="3"/>

android:

id="@+id/btu20"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="+"/>

android:

id="@+id/LayoutButtons5"

android:

layout_width="fill_parent"

android:

layout_height="wrap_content"

android:

layout_weight="2"

android:

orientation="horizontal">

android:

id="@+id/btu21"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="00"/>

android:

id="@+id/btu22"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="0"/>

android:

id="@+id/btu23"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="."/>

android:

id="@+id/btu24"

android:

layout_width="wrap_content"

android:

layout_height="fill_parent"

android:

layout_weight="1"

android:

text="="/>

(2)FmxActivity.java

packagecom.aa;

importandroid.app.Activity;

importandroid.os.Bundle;

importandroid.view.Menu;

importandroid.view.MenuItem;

importandroid.view.View;

importandroid.view.View.OnClickListener;

importandroid.widget.Button;

importandroid.widget.TextView;

importandroid.widget.Toast;

 

publicclassFmxActivityextendsActivity{

/**Calledwhentheactivityisfirstcreated.*/

privateintoption=0;//运算符状态

privatebooleannewdigital=true;//标记是否是新输入的数字

privatedoublea=0,b=0;//两个相加的数

privatedoublec;//表示取正负

privateButtonbtu1;

privateButtonbtu2;

privateButtonbtu3;

privateButtonbtu4;

privateButtonbtu5;

privateButtonbtu6;

privateButtonbtu7;

privateButtonbtu8;

privateButtonbtu9;

privateButtonbtu10;

privateButtonbtu11;

privateButtonbtu12;

privateButtonbtu13;

privateButtonbtu14;

privateButtonbtu15;

privateButtonbtu16;

privateButtonbtu17;

privateButtonbtu18;

privateButtonbtu19;

privateButtonbtu20;

privateButtonbtu21;

privateButtonbtu22;

privateButtonbtu23;

privateButtonbtu24;

publicvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

Buttonbtu1=(Button)findViewById(R.id.btu1);

Buttonbtu2=(Button)findViewById(R.id.btu2);

Buttonbtu3=(Button)findViewById(R.id.btu3);

Buttonbtu4=(Button)findViewById(R.id.btu4);

Buttonbtu5=(Button)findViewById(R.id.btu5);

Buttonbtu6=(Button)findViewById(R.id.btu6);

Buttonbtu7=(Button)findViewById(R.id.btu7);

Buttonbtu8=(Button)findViewById(R.id.btu8);

Buttonbtu9=(Button)findViewById(R.id.btu9);

Buttonbtu10=(Button)findViewById(R.id.btu10);

Buttonbtu11=(Button)findViewById(R.id.btu11);

Buttonbtu12=(Button)findViewById(R.id.btu12);

Buttonbtu13=(Button)findViewById(R.id.btu13);

Buttonbtu14=(Button)findViewById(R.id.btu14);

Buttonbtu15=(Button)findViewById(R.id.btu15);

Buttonbtu16=(Button)findViewById(R.id.btu16);

Buttonbtu17=(Button)findViewById(R.id.btu17);

Buttonbtu18=(Button)findViewById(R.id.btu18);

Buttonbtu19=(Button)findViewById(R.id.btu19);

Buttonbtu20=(Button)findViewById(R.id.btu20);

Buttonbtu21=(Button)findViewById(R.id.btu21);

Buttonbtu22=(Button)findViewById(R.id.btu22);

Buttonbtu23=(Button)findViewById(R.id.btu23);

Buttonbtu24=(Button)findViewById(R.id.btu24);

btu1.setOnClickListener(lisenter);

btu2.setOnClickListener(lisenter);

btu3.setOnClickListener(lisenter);

btu4.setOnClickListener(lisenter);

btu5.setOnClickListener(lisenter);

btu6.setOnClickListener(lisenter);

btu7.setOnClickListener(lisenter);

btu8.setOnClickListener(lisenter);

btu9.setOnClickListener(lisenter);

btu10.setOnClickListener(lisenter);

btu11.setOnClickListener(lisenter);

btu12.setOnClickListener(lisenter);

btu13.setOnClickListener(lisenter);

btu14.setOnClickListener(lisenter);

btu15.setOnClickListener(lisenter);

btu16.setOnClickListener(lisenter);

btu17.setOnClickListener(lisenter);

btu18.setOnClickListener(lisenter);

btu19.setOnClickListener(lisenter);

btu20.setOnClickListener(lisenter);

btu21.setOnClickListener(lisenter);

btu22.setOnClickListener(lisenter);

btu23.setOnClickListener(lisenter);

btu24.setOnClickListener(lisenter);

}

 

privateOnClickListenerlisenter=newOnClickListener()

{

publicvoidonClick(Viewv)

{

TextViewtext=(TextView)findViewById(R.id.text);

Strings=text.getText().toString();//获取文本框显示的字符串

Buttonbtu=(Button)v;

Stringt=(String)b

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

当前位置:首页 > 人文社科 > 文化宗教

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

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