Java和安卓实习报告.docx

上传人:b****3 文档编号:3442619 上传时间:2022-11-23 格式:DOCX 页数:15 大小:152.86KB
下载 相关 举报
Java和安卓实习报告.docx_第1页
第1页 / 共15页
Java和安卓实习报告.docx_第2页
第2页 / 共15页
Java和安卓实习报告.docx_第3页
第3页 / 共15页
Java和安卓实习报告.docx_第4页
第4页 / 共15页
Java和安卓实习报告.docx_第5页
第5页 / 共15页
点击查看更多>>
下载资源
资源描述

Java和安卓实习报告.docx

《Java和安卓实习报告.docx》由会员分享,可在线阅读,更多相关《Java和安卓实习报告.docx(15页珍藏版)》请在冰豆网上搜索。

Java和安卓实习报告.docx

Java和安卓实习报告

 

项目(设计)题目:

健康助手——最佳情侣身高测试

 

 

第一章项目背景及意义

在紧张的2周java及android实训后,作为一个结业的项目,由于时间原因,疏漏之处在所难免。

因为这是第一次接触和学习java语言和Android,所以一些比较复杂的项目我们是写不了的,所以就想写一个简单的健康小助手。

刚开始,在实习一个星期后,我们进行了分组。

小组成员确定下来后,在讨论做什么的时候,我们想了很多,但由于我们都是刚刚接触Java和Android,所以就想着选一个在我们这些初学者能力范围之内的项目。

经过一段时间的讨论,我们打算写一个健康小助手,让它包含计算器、体重计、最佳情侣身高匹配等小应用。

最后再经过一段时间的反复思考以及反复的方案设计和选定后,才确定下来。

这样一个健康的小插件,在人们的生活中也可以给人们带来很多方便。

比如计算器可以在人们需要计算大量数据的时候,可以为他们提供便利;体重计可以为你的身体健康提供帮助,可以帮你检测身体,如果你需要减肥,它将是你最好的伙伴;而最佳情侣身高匹配这一应用可以为你推荐你人生中另一半的身高,并评论你最佳情侣的身高和你心目中的最佳情侣身高的差距和你的幸福指数。

而我做的就是最佳情侣匹配这个小应用,主要帮助人们找到最适合自己的情侣的身高。

 

第二章基本知识

2.1基本知识

2.1.1JAVA基础

Jdk开发工具的安装以及使用:

到oracle官网下载windows安装包进行安装,然后进行环境变量配置,新建

JAVA_HOME=C:

\ProgramFiles(x86)\Java\jdk1.7.0_71,

CLASSPATH=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;

在path添加

%JAVA_HOME%\bin;

Java常见关键字:

class类,interface接口,public公共权限,private私有权限,protected受保护权限,extends继承,abstract抽象等。

Java数据类型:

逻辑型boolean,字符型char,整数型byte,short,int,

Long;浮点型:

float,double。

Java运算符:

算术运算符:

+,-,*,/,%,++,--;关系运算符:

>,<,>=,<=,==,!

=;逻辑运算符:

!

,&&,||;位运算符:

&,|,^,~,>>,<<,>>>;赋值运算符:

=;扩展赋值运算符:

+=,-=,*=,/=;字符串连接运算符:

+。

三目条件运算符,语法格式:

x?

y:

z。

Java语句:

条件语句-根据不同条件,执行不同语句。

if、if..Else、if..elseif、if..elseif..elseif..Else、switch;循环语句–重复执行某些动作:

for、for..each(JDK1.5语法)、while、do..While。

Java面向对象:

面向对象是针对面向过程的,传统的结构化程序设计通过一系列的过程(即算法)来求解问题,接着寻找存储数据的方式。

即算法是第一位的,而数据结构是第二位的。

OOP却调换了这个次序,将数据放在第一位,然后再考虑操纵数据的算法。

Java类、对象、特征:

类的概念,类的构成(属性、方法);对象的概念,初始化方法,方法的重载,this关键字;封装,继承(重写,super关键字,构造方法之继承),多态。

Java抽象类,接口,内部类,匿名内部类:

抽象类:

当编写一个类时,我们往往会为该类定义一些方法,这些方法是用来描述该类的行为方式,那么这些方法都有具体的方法体。

接口:

抽象类是从多个类中抽象出来的模板,若要将这种抽象进行得更彻底,就得用到一种特殊的“抽象类”;在一个类的内部定义的类就称为内部类,内部类可以处于4种访问级别(public、protected、默认和private);匿名内部类必须继承一个父类或者实现一个接口,但最多只能是一个父类或实现一个接口。

2.1.2android基础

Android体系结构:

Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑,由Google公司和开放手机联盟领导及开发。

另外android应用的范围不仅仅在手机,还被应用在汽车、平板电脑、和智能上网设备上、机顶盒以及智能穿戴设备。

Android开发环境:

下载安装JDK和Eclipse。

Android常见控件:

TextView、EditText、ImageView、Button、ImageButton、RadioButton、CheckBox、ProgressBar、RatingBar、Spinner、Dialog。

Android资源类型:

src/java原代码存放目录;gen/自动生成目录;assets资源目录;bin目录;libs目录;res/资源(Resource)目录;AndroidManifest.xml项目清单文件;default.properties;res/资源(Resource)目录;layout:

存放布局xml文件;menu:

存放菜单定义的xml文件。

Android界面设计:

Activity的创建与配置方式、Android界面跳转、Android界面间传值、Application用法、回调机制、Android生命周期、Android加载模式、Intent用法。

第三章项目详细设计

3.1需求概述

情侣间的身高差距影响着牵手、拥抱、接吻等等,对双方的感情培养有着关键的作用。

那么多少的身高差才是最适合的呢?

这就需要我们开发一个关于情侣之间最佳情侣身高的小应用,帮助人们找到最适合自己的情侣的身高。

3.2项目的功能

给你推荐适合你的最理想女朋友的身高,同时与你心目中的女生身高进行对比,并且对此进行评价,让你能更好的选择适合你的女友身高。

3.3运行及开发环境

运行环境:

Android,开发环境:

 JDK 和Eclipse

3.4模块详细设计及关键代码

3.4.1主界面设计

3.4.2xml代码

activity_lovers.xml:

android="

xmlns:

tools="

android:

layout_width="match_parent"

android:

layout_height="match_parent"

android:

paddingBottom="@dimen/activity_vertical_margin"

android:

paddingLeft="@dimen/activity_horizontal_margin"

android:

paddingRight="@dimen/activity_horizontal_margin"

android:

paddingTop="@dimen/activity_vertical_margin"

tools:

context="com.example.zuijiaqinglv.MainActivity$PlaceholderFragment">

id="@+id/res_content"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

textSize="18sp"

android:

textColor="#12f"

/>

id="@+id/res_not"

android:

layout_width="wrap_content"

android:

layout_below="@id/res_content"

android:

layout_height="wrap_content"

android:

layout_centerInParent="true"

android:

textSize="14sp"

android:

textColor="#f12"

android:

text="您好!

请填写您的信息:

"

/>

android:

id="@+id/editText1"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_alignBaseline="@+id/textView1"

android:

layout_alignBottom="@+id/textView1"

android:

layout_alignLeft="@+id/res_not"

android:

layout_marginLeft="49dp"

android:

ems="10"

android:

inputType="number"

android:

hint="输入您的身高/cm">

android:

id="@+id/res_gender"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_alignTop="@+id/textView2"

android:

layout_centerHorizontal="true"

>

android:

id="@+id/res_rb_man"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

checked="true"

android:

text="男"/>

android:

id="@+id/res_rb_woman"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

text="女"/>

android:

id="@+id/textView2"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_alignLeft="@+id/textView1"

android:

layout_below="@+id/editText1"

android:

layout_marginTop="19dp"

android:

text="性别:

"/>

android:

id="@+id/EditText02"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_alignLeft="@+id/res_content"

android:

layout_alignRight="@+id/editText1"

android:

layout_below="@+id/TextView01"

android:

ems="10"

android:

hint="输入您心中最佳情侣的身高/cm"

android:

inputType="number"/>

android:

id="@+id/TextView01"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_alignLeft="@+id/textView2"

android:

layout_below="@+id/res_gender"

android:

text="您理想中最佳情侣的身高:

"/>

android:

id="@+id/textView1"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_below="@+id/res_not"

android:

layout_marginTop="30dp"

android:

text="您的身高:

"/>

android:

id="@+id/buttonn"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_below="@+id/EditText02"

android:

layout_marginTop="44dp"

android:

paddingLeft="80dp"

android:

paddingRight="80dp"

android:

layout_centerHorizontal="true"

android:

text="检测"/>

activity_show.xml:

android="

xmlns:

tools="

android:

layout_width="match_parent"

android:

layout_height="match_parent"

android:

paddingBottom="@dimen/activity_vertical_margin"

android:

paddingLeft="@dimen/activity_horizontal_margin"

android:

paddingRight="@dimen/activity_horizontal_margin"

android:

paddingTop="@dimen/activity_vertical_margin"

tools:

context="com.yangji.login.MainActivity$PlaceholderFragment">

id="@+id/main_text"

android:

layout_width="match_parent"

android:

layout_height="wrap_content"

android:

layout_centerInParent="true"

android:

textSize="20sp"

android:

textColor="#f12"/>

android:

id="@+id/button1"

android:

layout_width="wrap_content"

android:

layout_height="wrap_content"

android:

layout_alignParentBottom="true"

android:

layout_alignRight="@+id/main_text"

android:

layout_marginBottom="19dp"

android:

layout_marginRight="66dp"

android:

onClick="exit"

android:

text="返回"/>

3.4.3后台代码

LoversActivity.java:

packagecom.example.job;

importandroid.content.Intent;

importandroid.os.Bundle;

importandroid.support.v7.app.ActionBarActivity;

importandroid.view.View;

importandroid.view.View.OnClickListener;

importandroid.widget.Button;

importandroid.widget.EditText;

importandroid.widget.RadioButton;

importandroid.widget.RadioGroup;

importandroid.widget.Toast;

publicclassLoversActivityextendsActionBarActivityimplements

OnClickListener{

privateEditTextheightEt;

privateRadioGroupgenderRg;

privateRadioButtonmaleRb;

privateRadioButtonfemaleRb;

privateEditTextholeHeightEt;

privateButtoncheckBtn;

@Override

protectedvoidonCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_lovers);//设置显示视图

//找到界面各组件

heightEt=(EditText)findViewById(R.id.editText1);

genderRg=(RadioGroup)findViewById(R.id.res_gender);

maleRb=(RadioButton)findViewById(R.id.res_rb_man);

femaleRb=(RadioButton)findViewById(R.id.res_rb_woman);

holeHeightEt=(EditText)findViewById(R.id.EditText02);

checkBtn=(Button)findViewById(R.id.buttonn);

checkBtn.setOnClickListener(this);

}

//处理组件点击事件

@Override

publicvoidonClick(Viewview){

switch(view.getId()){

caseR.id.buttonn:

checkHeight();

break;

}

}

//检测并评论身高

privatevoidcheckHeight(){

if(heightEt.getText().toString().length()==0){

Toast.makeText(this,"您的身高不能为空",Toast.LENGTH_LONG).show();

}elseif(holeHeightEt.getText().toString().length()==0){

Toast.makeText(this,"最佳情侣身高不能为空",Toast.LENGTH_LONG).show();

}else{

intheight=Integer.parseInt(heightEt.getText().toString());

inthopeHeight=Integer

.parseInt(holeHeightEt.getText().toString());

floatobjHeight=0f;

intresId=genderRg.getCheckedRadioButtonId();

if(resId==R.id.res_rb_man){

//男生

objHeight=(float)(height/1.09);

}elseif(resId==R.id.res_rb_woman){

//女生

objHeight=(float)(height*1.09);

}else{

//人妖

objHeight=(float)height;

}

Stringnotice="您的身高:

【"+height+"】\n您期望对象的身高:

【"+hopeHeight

+"】\n推荐对象身高:

【"+objHeight+"】\n评论:

";

if((objHeight-hopeHeight)>15){

notice+="靠!

你们要逆天啊!

";

}

elseif((hopeHeight-objHeight)>15){

notice+="靠!

你们要逆天啊!

";

}

elseif((objHeight-hopeHeight)>10){

notice+="你们差距太大,可远观不可亵玩焉!

";

}

elseif((hopeHeight-objHeight)>10){

notice+="你们差距不大,但择偶请慎重!

";

}

elseif((hopeHeight-objHeight)>5){

notice+="你们差距太大,可远观不可亵玩焉!

";

}

elseif((objHeight-hopeHeight)>5){

notice+="你们差距太大,可远观不可亵玩焉!

";

}

else{

notice+="你们真是郎才女貌,天生一对!

";

}

Intentintent=newIntent(this,ShowActivity.class);

Bundlebundle=newBundle();

bundle.putString("notice",notice);

intent.putExtras(

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

当前位置:首页 > 党团工作 > 入党转正申请

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

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