通信与信息工程学院
班 级:姓 名:学 号:指导教师:设计时间:成 绩:
评 语:专业技能课程设计
电子科学与技术1202班
2015/1/4—2015/1/16
通信与信息工程学院
二〇一五年
目录
一、 二、 三、
设计题目: ..................................................................................................... 2 设计要求: ..................................................................................................... 2 设计原理 ......................................................................................................... 2
1、 搭建环境: ..................................................................................................... 2 2、 设计步骤: ..................................................................................................... 2 3、 设计框图: ..................................................................................................... 2 4、 设计原理: ..................................................................................................... 3 四、
设计代码: ..................................................................................................... 6
1、 main.xml .......................................................................................................... 6 2、 layout next.xml .............................................................................................. 13 3、 values strings.xml .......................................................................................... 14 4、 values year.xml .............................................................................................. 15 5、 src mainactivity.java ...................................................................................... 16 6、 src next.java ................................................................................................ 19 五、 六、 七、
出现问题 ....................................................................................................... 21 提问答疑 ....................................................................................................... 21 设计心得 ....................................................................................................... 22
壱、
设计题目:
Android个人简历制作 弐、
设计要求:
1
学会安装Java、sdk及Java软件在Windows操作系统中环境变量的设置,让其保证在个人操作系统上的可用性。在了解Java语言和eclipse软件的基础上熟知软件和语言的应用,运用Java语言和对eclipse软件平台的操作制作个人简历,在输入姓名、选择性别、兴趣和其他资料项后生成简历,并且在安卓虚拟机或安卓手机上成功运行。
参、 设计原理
1、 搭建环境:
操作系统版本:Windows7 x旗舰版
设计所需软件:Java软件,Sdk包,eclipse平台 2、 设计步骤:
首先确保Java软件在操作系统的安装成功。安装后系统环境变量的设置决定软件的可使用性,可根据个人的系统版本进行更改,软件及平台可由个人所好更改界面语言。 安装完成后,进入eclipse平台,调入Sdk包,并设置所需虚拟机配置,然后通过对软件和语言进行了解后开始简单的设计。
在掌握基础后,根据要求建立个人简历屏幕上所需的按钮、文字提示、滚动条、复选框以及背景和颜色的更改,利用跳转来实现个人简历最后的生成。并根据个人操作系统的配置运行合适配置的安卓虚拟机来调试和运行软件。
3、 设计框图:
4、 设计原理:
安装Java时,要注意的是操作系统上对环境变量的配置。打开“我的电脑”属性中的环境变量,添加或编辑以下系统变量:
JAVA_HOME Java安装目录\\Java\\jdk1.6.0_21 CLASSPATH .;%JAVA_HOME%\\lib\ools.jar
2
建立个人信息选填页面 使用相关函数生成按钮及框架 使用跳转按钮,并配置建立简历生成页面 调试,检错并修改 在虚拟机上运行个人简历 Path %JAVA_HOME%\\bin;%JAVA_HOME%\\jre\\bin;
进入eclipse平台调入Sdk包(图4—1)。
图4-1
配置合适的安卓虚拟机(图4-2)图中lll命名的是7寸平板大小的安卓虚拟机,qdd命名的是3.2寸手机大小的安卓虚拟机,根据个人喜好和系统配置进行选择。在最后我选择的小型的安卓虚拟机,开机速度相对较快,需要占用的内存和资源较小(图4-3)。
3
图4-2
4
图4-3
在eclipse平台建立新的项目,在显示屏幕用TextView添加提示文字,用EditText添加姓名输入框,用RelativeLayout添加性别和兴趣的选项,用LinearLayout添加出生年月、籍贯和学校的选择,用Button添加跳转按钮“生成简历”,用ScrollView添加滚动条,第一页面就生成了(图4-4)。再对文字及背景利用相关函数进行配置,在第二页面进行相关配置,加入个人头像,并对背景进行与第一页面单色的背景不同的配置,使用了图片作为背景(图4-5)。
5
图4-4
图4-5
四、 设计代码:
1、 main.xml
xmlns:android=\"http://schemas.android.com/apk/res/android\"> 6 android:layout_height=\"match_parent\" android:orientation=\"vertical\" android:background=\"#9933ff\" >//背景颜色代码 android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:layout_gravity=\"center_horizontal\" android:text=\"个人简历\" android:textColor=\"#ffff00\"//文字颜色代码 android:textSize=\"30dp\" />//文字大小代码 android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:text=\"姓名:\" android:textColor=\"#ffff00\"/> 7 android:layout_toRightOf=\"@id/text2\" android:textColor=\"#ffff00\"/>//输入文字大小代码 android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:text=\"性别:\" android:textColor=\"#ffff00\"/> android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:layout_alignBottom=\"@id/text3\" android:layout_toRightOf=\"@id/text3\" android:orientation=\"horizontal\"//水平布局 android:textColor=\"#ffff00\" > 8 android:textColor=\"#ffff00\" android:checked=\"true\"/>\" //性别复选框 android:textColor=\"#ffff00\"/> 以下为出生年月布局与文字颜色设置代码 android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:text=\"出生年月:\" android:textColor=\"#ffff00\"/> android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:calendarViewShown=\"false\" android:textColor=\"#ffff00\"/> 9 以下为籍贯布局与文字颜色设置代码 android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:text=\"籍贯:\" android:textColor=\"#ffff00\"/> android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:entries=\"@array/province\" android:textColor=\"#ffff00\" /> 以下为学校布局与文字颜色设置代码 10 android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:text=\"学校:\" android:textColor=\"#ffff00\"/> android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:entries=\"@array/school\" android:textColor=\"#ffff00\" /> 以下为兴趣爱好布局与文字颜色设置代码 android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:text=\"兴趣爱好:\" android:textColor=\"#ffff00\"/> 其中,以下的checkbox均为各兴趣爱好的复选框代码 11 android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:layout_alignBottom=\"@id/text5\" android:layout_toRightOf=\"@id/text5\" android:text=\"运动\" android:textColor=\"#ffff00\"/> android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:layout_alignBottom=\"@id/cb1\" android:layout_toRightOf=\"@id/cb1\" android:checked=\"true\" android:text=\"听音乐\" android:textColor=\"#ffff00\"/> android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:layout_alignBottom=\"@id/cb2\" android:layout_toRightOf=\"@id/cb2\" android:text=\"网游\" android:textColor=\"#ffff00\"/> android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:layout_alignBottom=\"@id/cb3\" 12 android:layout_toRightOf=\"@id/cb3\" android:text=\"看电影\" android:textColor=\"#ffff00\"/> android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:layout_alignBottom=\"@id/cb4\" android:layout_toRightOf=\"@id/cb4\" android:text=\"阅读\" android:textColor=\"#ffff00\"/> android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:layout_alignBottom=\"@id/cb5\" android:layout_toRightOf=\"@id/cb5\" android:text=\"旅游\" android:textColor=\"#ffff00\"/> android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:layout_alignBottom=\"@id/cb6\" android:layout_toRightOf=\"@id/cb6\" android:text=\"其他\" android:textColor=\"#ffff00\"/>
xmlns:android=\"http://schemas.android.com/apk/res/android\"> 布局设置及背景图片设置 android:background=\"@drawable/qb\">//背景图片地址代码 android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:layout_gravity=\"center_horizontal\" android:text=\"个人简历\" android:textColor=\"#000000\" android:textSize=\"25dp\" /> 14 生成简历页面头像大小与图片地址 android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:text=\"个人简历\" android:textSize=\"25dp\" android:textColor=\"#000000\"/>
出生年月日复选框代码
15
4、 values year.xml
5、 src mainactivity.java
生成文件及各相关链接,以及各id地址链接代码,使其与之相关联,并生成 package com.example.dddd;
16
import android.support.v4.app.Fragment; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem;
import android.view.View.OnClickListener; import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.CheckBox; import android.widget.DatePicker; import android.widget.EditText; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.Spinner; import android.widget.TextView; import android.os.Build;
public class MainActivity extends Activity {
String name, sex, province,school, hobby = \"\"; int year, month, day; EditText edit1;
CheckBox cb1, cb2, cb3, cb4,cb5,cb6,cb7; RadioButton rb1, rb2; Button bt; DatePicker dp;
17
Spinner sp,spi;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.main);
edit1 = (EditText) findViewById(R.id.edit1); bt = (Button) findViewById(R.id.bt); rb1 = (RadioButton) findViewById(R.id.rb1); rb2 = (RadioButton) findViewById(R.id.rb2); dp = (DatePicker) findViewById(R.id.dp); sp = (Spinner) findViewById(R.id.sp); spi = (Spinner) findViewById(R.id.spi); cb1 = (CheckBox) findViewById(R.id.cb1); cb2 = (CheckBox) findViewById(R.id.cb2); cb3 = (CheckBox) findViewById(R.id.cb3); cb4 = (CheckBox) findViewById(R.id.cb4); cb5 = (CheckBox) findViewById(R.id.cb5); cb6 = (CheckBox) findViewById(R.id.cb6); cb7 = (CheckBox) findViewById(R.id.cb7); bt.setOnClickListener(new OnClickListener() {
各兴趣爱好内容选择代码
@Override
public void onClick(View v) {
hobby = \"\";
name = edit1.getText().toString(); if (cb1.isChecked()) { }
18
hobby = hobby + \"运动\" + \" \";
if (cb2.isChecked()) { }
if (cb3.isChecked()) { }
if (cb4.isChecked()) { }
hobby = hobby + \"看电影\" + \" \"; hobby = hobby + \"玩网游\" + \" \"; hobby = hobby + \"听音乐\" + \" \";
if (cb5.isChecked()) {
}
if (cb6.isChecked()) { }
if (cb7.isChecked()) { }
性别选择代码
if (rb1.isChecked()) {
hobby = hobby + \"其他\" + \" \"; hobby = hobby + \"旅游\" + \" \"; hobby = hobby + \"阅读\" + \" \";
sex = \"男\";
} else { }
year = dp.getYear();
sex = \"女\";
month = dp.getMonth() + 1; day = dp.getDayOfMonth();
province = sp.getSelectedItem().toString(); school = spi.getSelectedItem().toString();
19
}
}
Intent intent = new Intent(MainActivity.this, next.class); intent.putExtra(\"name\intent.putExtra(\"sex\
intent.putExtra(\"province\intent.putExtra(\"school\intent.putExtra(\"hobby\intent.putExtra(\"year\intent.putExtra(\"month\intent.putExtra(\"day\
MainActivity.this.startActivity(intent);
});
}
6、 src next.java
生成简历页面的显示方式与布局 package com.example.dddd;
import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.widget.TextView;
public class next extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.next);
20
Intent intent = super.getIntent();
String name = intent.getStringExtra(\"name\"); String sex = intent.getStringExtra(\"sex\");
String province = intent.getStringExtra(\"province\"); String school = intent.getStringExtra(\"school\"); String hobby = intent.getStringExtra(\"hobby\"); int year = intent.getIntExtra(\"year\int month = intent.getIntExtra(\"month\int day = intent.getIntExtra(\"day\
TextView tv = (TextView) findViewById(R.id.text2); tv.setText(\"姓名:\" + name + \"\\n \" +\"性别:\"+ sex + \"\\n\" +\"省份:\" +\"学校:\"
+ province + \"\\n\" + school + \"\\n\"
+\"兴趣:\"+ \"\" + hobby+ \"\\n\" +\"出生年月:\" + month + \"\"+\"月\"
+year + \"\"+\"年\"
+ day + \"\"+\"日\"+ \"\\n\"); }
}
伍、
出现问题
在3.2寸安卓虚拟机上运行个人简历时,由于第一界面内容较多,生成简历跳转按钮和学校选项未能显示在屏幕上,最初使用7寸安卓虚拟机代替3.2寸安卓虚拟机使两项显示。之后通过网络搜索和相关资料阅读,在多次调试后找到解决方法,使其在3.2寸设备上可以正常运行及跳转。
滚动条配置代码如下,可根据软件自行调整: 21 xmlns:android=\"http://schemas.android.com/apk/res/android\"> ScrollView > 六、 提问答疑 问题:怎么新建一个类似于兴趣爱好的复选框? 答:利用CheckBox函数,在main.xml添加以下函数 android:layout_toRightOf=\"@id/**\" //以上四行为复选框布局 android:text=\" *\" //界面上现实的文字 android:textColor=\"#ffff00\"/> //界面上显示文字的颜色 之后在src下mainactivity.java内找到一下代码,并添加,若无则直接添加。 CheckBox cb1, cb2,*; * = (CheckBox) findViewById(R.id.*); @Override public void onClick(View v) { hobby = \"\"; name = edit1.getText().toString(); if (*.isChecked()) { hobby = hobby + \"运动\" + \" \"; } 七、 设计心得 通过本次课程设计,我对Android和java编程有了不同的看法,之前认为java相对于c语言来说是枯燥乏味的,也没太大的乐趣,现在对Android中的常用类和接口有了进一步的认识,对编程有了一种新的看法,编程在我的学习中不再是那样的无味,而是时时刻刻充满惊喜。相对于c语言,java更加显得可爱,在制作Android apt软件时,更能亲手体会对其做出改变和美化效果的乐趣,虽然这是一个挺小的项目但它对我在编程方面起到了一种激励的作用。我会在此基础上更加努力做出更好的程序。 22
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- cepb.cn 版权所有 湘ICP备2022005869号-7
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务