安瑞范文网

移动终端开发实验报告

|来源:网友投稿

  软件学院

 学 生 实 验 报 告

 实验课程

  移动终端开发

 开课时间

  2019

 至

 2020

 学年

 第 2 学期

  年

 级

 2017

  专业班

  计科 5 班

 姓

 名

  王帅兵

  学

 号

 20177710541

  总 成 绩

 教师签名

 软件学院制

 实验教学管理基本规范

 实验是培养学生动手能力、分析解决问题能力的重要环节;实验报告是反映实验教学水平与质量的重要依据。为加强实验过程管理,改革实验成绩考核方法,改善实验教学效果,提高学生质量,特制定实验教学管理基本规范。

 1、 每门实验课程一般会包括多个实验项目,除非常简单的验证演示性实验项目可以不写实验报告外,其他实验项目均应按本格式完成实验报告。

 2、 实验报告应由实验准备、实验过程、结果分析三大部分组成。每部分均在实验成绩中占一定比例。各部分成绩的观测点、考核目标、所占比例可参考附表执行。各专业可以根据具体情况,调整考核内容和评分标准。

 3、 学生必须在完成实验预习内容的前提下进行实验。教师要在实验过程中抽查学生预习情况,在学生离开实验室前,检查学生实验操作和记录情况,并在实验报告第七部分教师签字栏签名,以确保实验记录的真实性。

 4、 、 教师应及时评阅学生的实验报告并给出各实验项目成绩,完整保存实验报告。在完成所有实验项目后,教师应按学生姓名将批改好的各实验项目实验报告装订成册,构成该实验课程总报告,按班级交课程承担单位(实验中心或实验室)保管存档。

 5、 、 实验课程成绩按其类型采取百分制或优、良、中、及格和不及格五级评定。

 附表:

 实验考核参考内容及标准

 观测点 考核目标 成绩组成 实验准备 1. 预习报告 2. 提问 3. 对于设计型实验,着重考查设计方案的科学性、可行性和创新性 对实验目的和基本原理的认识程度,对实验方案的设计能力 20% 实验过程 1. 是否按时参加实验 2. 对实验过程的熟悉程度 3. 对基本操作的规范程度 4. 对突发事件的应急处理能力 5. 实验原始记录的完整程度 6. 同学之间的团结协作精神 着重考查学生的实验态度、基本操作技能;严谨的治学态度、团结协作精神 30% 结果分析 1. 所分析结果是否用原始记录数据 2. 计算结果或软件运行结果是否正确 3. 实验结果分析是否合理 4. 对于综合实验,各项内容之间是否有分析、比较与判断等 考查学生对实验数据处理和现象分析的能力;对专业知识的综合应用能力;事实求实的精神 50%

 实验一 实验名称 Android Studio 集成开发环境部署 指导老师 李俊锋 实验教室

 实验时间 2020.2.21 实验成绩

 实 验 目 的

  (给出本次实验要求掌握的知识点、技能等)

 1. 掌握 Android Studio 的安装和配置过程; 2. 掌握创建一个 Android 应用程序的基本流程; 3. 了解 Android 应用程序的目录结构; 4. 熟悉 Android 应用程序的常用文件的基本用途; 5. 掌握编译、运行一个 Android 应用程序的基本方法。

  实 验 环 境

 (列出本次实验所使用的平台、器材和相关软件等)

 部署有 Android Studio 和 Android SDK 的主机。

  实 验 准 备

 ( 硬件相关实验给出本实验实验原理;软件相关实验给出本实验涉及的相关知识点 )

  1. 在 Android Studio 中创建一个 Android 应用。

 2. 熟悉 Android Studio 下 Android 项目的目录结构及各文件的基本用途。

 实 验 内 容 及 实 验 步 骤

  ( 给出实验内容具体描述;硬件相关实验给出实验步骤和实验原始记录;软件相关实验给出程序清单、调试过程出现的问题以及解决方法、运行结果等)

 程序代码:

 MainActivity.java: package com.example.helloworld; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle;

 public class MainActivity extends AppCompatActivity {

 @Override

  protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_main);

  } } activity_main.xml:

 <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"

  xmlns:app="http://schemas.android.com/apk/res-auto"

  xmlns:tools="http://schemas.android.com/tools"

  android:layout_width="match_parent"

  android:layout_height="match_parent"

  tools:context=".MainActivity">

 <TextView

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:text="Hello World!"

  app:layout_constraintBottom_toBottomOf="parent"

  app:layout_constraintLeft_toLeftOf="parent"

  app:layout_constraintRight_toRightOf="parent"

  app:layout_constraintTop_toTopOf="parent" />

 </androidx.constraintlayout.widget.ConstraintLayout>

 实 验 结 果 及 分 析

 (对实验结果进行分析、总结实验心得体会以及改进建议)

 1.在 Android Studio 中创建我的第一个 Android 应用程序 HelloWord。

 2.熟悉了 Android Studio 下 Android 项目的目录结构及各文件的基本用途。

 教 师 评 语

  (教师对该生的实验准备、实验步骤、实验结果分析以及实验态度给出综合评价)

 教师签名:

  年

  月

  日

 实验二 实验名称 布局管理器及简单控件的使用

 指导老师 李俊锋 实验教室

 实验时间

 实验成绩

 实 验 目 的

  (给出本次实验要求掌握的知识点、技能等)

 1. 掌握 Android 常用的几种布局管理器; 2. 掌握 TextView、EditText、Button 等常见控件的使用方法; 3. 能够熟练应用各种布局管理器及控件进行界面设计。

  实 验 环 境 (列出本次实验所使用的平台、器材和相关软件等)

 1、部署有 Android Studio 和 Android SDK 的主机; 2、建议在机房的 HelloWorld 例子上完成。

  实 验 准 备

 ( 硬件相关实验给出本实验实验原理;软件相关实验给出本实验涉及的相关知识点 )

 在 layout 文件夹的布局文件 activity_main.xml 中设计如下登陆界面(布局管理器不限,可自由嵌套组合,只要运行得到如下界面即可)。

 实 验 内 容 及 实 验 步 骤

  ( 给出实验内容具体描述;硬件相关实验给出实验步骤和实验原始记录;软件相关实验给出程序清单、调试过程出现的问题以及解决方法、运行结果等)

 (1)以下是三个 drawable 文件,需复制到 drawable 文件夹。

 editext_selector.xml:编辑框的有无焦点时的边框绘制,引用了下面两个文件。

 shape_edit_focus.xml:编辑框获取焦点时的边框 shape_edit_normal.xml:编辑框没有获取焦点时的获边框 (2)颜色值文件 colors.xml,复制到 values 文件夹。

 (3)部分程序代码 MainActivity.java :

 public class MainActivity extends AppCompatActivity {

 @Override

  protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

  // 加载布局

 setContentView(R.layout.activity_main);

  // 获取控件

 tv_password = findViewById(R.id.tv_password); ......

  btn_login=findViewById(R.id.btn_login);

  // 单选按钮组绑定监听器

 rg_login.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

  @Override

  public void onCheckedChanged(RadioGroup group, int checkedId) {

  if (checkedId == R.id.rb_password) {

  tv_password.setText(" 登录密码:");

  et_password.setHint(" 请输入密码");

  btn_forget.setText(" 忘记密码");

  ck_remember.setVisibility(View.VISIBLE);

  } else if (checkedId == R.id.rb_verifycode) {

  tv_password.setText(" 验证码:");

  et_password.setHint(" 请输入验证码");

  btn_forget.setText(" 获取验证码");

  ck_remember.setVisibility(View.INVISIBLE);}}});

  btn_login.setOnClickListener(new View.OnClickListener() {

  @Override

  public void onClick(View view) {

  Toast.makeText(MainActivity.this," 登录成功",Toast.LENGTH_SHORT).show();

  }});}}

 实 验 内 容 及 实 验 步 骤

  LoginActivity.java: public class LoginActivity extends AppCompatActivity {

  private TextView btn_login;

  @Override

  protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_login);

  btn_login=findViewById(R.id.tv_1);

  btn_login.setOnClickListener(new View.OnClickListener() {

  @Override

  public void onClick(View view) {

  Toast.makeText(LoginActivity.this," 登录成功",Toast.LENGTH_SHORT).show();}});}

  public void showToast(View view) {

  Toast.makeText(this," 登录成功",Toast.LENGTH_SHORT).show();}} activity_login.xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

  android:layout_width="match_parent"

  android:layout_height="match_parent">

  <TextView

  android:id="@+id/tv_1"

  android:layout_width="match_parent"

  android:layout_height="match_parent"

  android:text="1222222"

  android:textSize="20dp"></TextView> </LinearLayout> activity_main.xml: <LinearLayout>

  <RadioGroup

  android:id="@+id/rg_login"

  android:layout_width="match_parent"

  android:layout_height="wrap_content"

  android:orientation="horizontal"

  android:layout_marginTop="15dp">

  <RadioButton

  android:id="@+id/rb_password"

  android:padding="5dp"

  android:layout_width="match_parent"

  android:layout_height="wrap_content"

  android:layout_weight="1"

  android:checked="true"

  android:text=" 密码登录"/> </RadioGroup></LinearLayout>

 实 验 内 容 及 实 验 步 骤

  <RelativeLayout

  android:layout_width="0dp"

  android:layout_height="wrap_content"

  android:layout_weight="3">

  <EditText

  android:id="@+id/et_password"

  android:layout_width="match_parent"

  android:layout_height="40dp"

  android:hint=" 请输入密码"

  android:layout_marginTop="10dp"

  android:background="@drawable/editext_selector"

  android:inputType="textPassword">

  </EditText>

  <Button

  android:id="@+id/btn_forget"

  android:layout_width="wrap_content"

  android:layout_height="40dp"

  android:text=" 忘记密码"

  android:layout_marginTop="10dp"

  android:layout_alignRight="@id/et_password"

  android:layout_alignEnd="@id/et_password" /> </RelativeLayout> <CheckBox

  android:id="@+id/ck_remember"

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:textColor="#FF4081"

  android:text=" 记住密码"

  android:layout_marginTop="10dp"

  android:textSize="16sp" /> <Button

  android:id="@+id/btn_login"

  android:layout_width="match_parent"

  android:layout_height="wrap_content"

  android:layout_marginTop="10dp"

  android:text=" 登录"

  android:textSize="20sp" />

 实 验 结 果 及 分 析

 (对实验结果进行分析、总结实验心得体会以及改进建议)

  运行截图:

 教 师 评 语

  (教师对该生的实验准备、实验步骤、实验结果分析以及实验态度给出综合评价)

 教师签名:

  年

  月

  日

 实验三 实验名称 w ImageView 和 和 h Switch 的使用

 指导老师 李俊锋 实验教室

 实验时间

 实验成绩

  实 验 目 的 (给出本次实验要求掌握的知识点、技能等)

 1. 掌握 Android 中 ImageView 和 Switch 控件的使用; 2. 能够熟练应用各种控件进行界面设计。

  实 验 环 境 (列出本次实验所使用的平台、器材和相关软件等)

 1. 部署有 Android Studio 和 Android SDK 的主机; 2. 建议在机房的 HelloWorld 例子上完成。

  实 验 准 备

 ( 硬件相关实验给出本实验实验原理;软件相关实验给出本实验涉及的相关知识点 )

 在 layout 文件夹的布局文件 activity_main.xml 中设计如下界面。

 实 验 内 容 及 实 验 步 骤

  ( 给出实验内容具体描述;硬件相关实验给出实验步骤和实验原始记录;软件相关实验给出程序清单、调试过程出现的问题以及解决方法、运行结果等)

 (1)以下是 drawable 文件,需复制到 drawable 文件夹。

  apple.png:界面最上面的 ImageView 控件显示的图片  check.gif:Switch 开关的滑块图片  dark.png:界面最下面的 ImageView 控件显示的图片(Switch 关时)

  light.png:界面最下面的 ImageView 控件显示的图片(Switch 开时)

 (2)颜色值文件 colors.xml,复制到 values 文件夹。

 (3)部分程序代码 MainActivity.java public class MainActivity extends AppCompatActivity {

  @Override

  protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_main);

  apple_1=findViewById(R.id.apple_1); ......

  image_on_off=findViewById(R.id.image_on_off);

  switch_1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

  @Override

  public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

  if(isChecked){image_on_off.setImageResource(R.drawable.light);}

  else{image_on_off.setImageResource(R.drawable.dark);}}});

  setListeners();}

  private class OnClick implements View.OnClickListener{

  @Override

  public void onClick(View view){

  switch (view.getId()){

  case R.id.fitcenter:

  apple_1.setScaleType(ImageView.ScaleType.FIT_CENTER);

  break;

  ......

  default:

  break;}}}

  private void setListeners(){

  OnClick onclick=new OnClick();

  fitcenter.setOnClickListener(onclick);

  centercrop.setOnClickListener(onclick);

  centerinside.setOnClickListener(onclick);

  center.setOnClickListener(onclick);

  fitxy.setOnClickListener(onclick);

  fitstart.setOnClickListener(onclick);

  fitend.setOnClickListener(onclick);}}

 实 验 内 容 及 实 验 步 骤

  activity_main.xml: <ImageView

  android:id="@+id/apple_1"

  android:layout_width="match_parent"

  android:layout_height="wrap_content"

  android:src="@drawable/apple"

  android:background="@color/yellow"></ImageView> <Button

  android:id="@+id/fitcenter"

  android:layout_width="0dp"

  android:layout_height="wrap_content"

  android:layout_weight="1"

  android:text="FITCENTER"

  android:textSize="16sp"></Button>

 <LinearLayout

  android:layout_width="match_parent"

  android:layout_height="wrap_content"

  android:orientation="horizontal"

  android:layout_marginTop="15dp">

  <TextView

  android:layout_width="0dp"

  android:layout_height="wrap_content"

  android:layout_weight="1"

  android:text=" 请滑动开关选择开关灯"

  android:textSize="18sp"

  android:textColor="@color/black"

  android:gravity="right"></TextView>

  <Switch

  android:id="@+id/switch_1"

  android:layout_width="0dp"

  android:layout_height="wrap_content"

  android:thumb="@drawable/check"

  android:layout_weight="1"

  android:checked="false"

  android:layout_marginRight="30dp"></Switch>

  </LinearLayout>

  <ImageView

  android:id="@+id/image_on_off"

  android:layout_width="match_parent"

  android:layout_height="wrap_content"

  android:src="@drawable/dark"

  android:layout_marginTop="15dp"></ImageView> </LinearLayout>

 实 验 结 果 及 分 析

 运行截图:

  教 师 评 语

  (教师对该生的实验准备、实验步骤、实验结果分析以及实验态度给出综合评价)

 教师签名:

  年

  月

  日

 实验四 实验名称 w ListView 的使用

 指导老师 李俊锋 实验教室

 实验时间

 实验成绩

 实 验 目 的 (给出本次实验要求掌握的知识点、技能等)

 1. 掌握 Android 中 ListView 控件的使用; 2. 掌握各种 Adapter 封装数据的方法; 3. 能够熟练应用各种布局管理器和控件进行界面设计。

 实 验 环 境 (列出本次实验所使用的平台、器材和相关软件等)

 1. 部署有 Android Studio 和 Android SDK 的主机; 2. 建议在机房的 HelloWorld 例子上完成。

  实 验 准 备

 ( 硬件相关实验给出本实验实验原理;软件相关实验给出本实验涉及的相关知识点 )

 在 layout 文件夹的布局文件 activity_main.xml 中设计如下界面。

 实 验 内 容 及 实 验 步 骤

  ( 给出实验内容具体描述;硬件相关实验给出实验步骤和实验原始记录;软件相关实验给出程序清单、调试过程出现的问题以及解决方法、运行结果等)

 (1)以下是 drawable 文件,需复制到 drawable 文件夹。

  shuixing.jpg:水星图片  ......  tuxing.jpg:土星图片 (2)部分程序代码:

 MainActivity.java:

 public class MainActivity extends AppCompatActivity {

  private ListView lv_1;

  private SimpleAdapter adapter;

  // 行星名称数组

 private String[] names = new String[]{" 水星", " 金星", " 地球", " 火星", " 木星", " 土星"};

  // 行星描述数组

 private String[] descs = new String[]{

  " 水星是太阳系八大行星最内侧也是最小的一颗行星,也是离太阳最近的行星。",

  " 金星是太阳系八大行星之一,排行第二,距离太阳 0.725 天文单位。",

  " 地球是太阳系八大行星之一,排行第三,也是太阳系中直径、质量和密度最大的类地行星。",

  " 火星是太阳系八大行星之一,排行第四,属于类地行星,直径约为地球的 53% 。",

  " 木星是太阳系八大行星中体积最大、自转最快的行星,排行第五。它的质量为太阳的千分之一。",

  " 土星为太阳系八大行星之一,排行第六,体积仅次于木星。"};

  // 行星图片数组

 private int[] imageIds = new int[]{R.drawable.shuixing, R.drawable.jinxing,

  R.drawable.diqiu, R.drawable.huoxing, R.drawable.muxing, R.drawable.tuxing};

  @Override

  protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_main);

  lv_1=findViewById(R.id.lv_1);

  adapter=new SimpleAdapter(MainActivity.this,getData(),R.layout.list_item,

  new String[]{"image","title","content"},

  new int[]{R.id.iv,R.id.tv_title,R.id.tv_content});

  lv_1.setAdapter(adapter);}

  private List<Map<String,Object> >getData(){

  List<Map<String,Object> >lists=new ArrayList< Map<String, Object>>();

  for(int i=0;i<6;i++){

  Map<String,Object> mp=new HashMap<String,Object>();

  mp.put("image",imageIds[i]);

  mp.put("title",names[i]);

  mp.put("content",descs[i]);

  lists.add(mp);

  }

  return lists;}}

 实 验 内 容 及 实 验 步 骤

  activity_main.xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

  android:layout_width="match_parent"

  android:layout_height="match_parent"

  android:orientation="vertical">

  <ListView

  android:id="@+id/lv_1"

  android:layout_width="match_parent"

  android:layout_height="wrap_content"></ListView> </LinearLayout> list_item.xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

  android:orientation="horizontal"

  android:layout_width="match_parent"

  android:layout_height="wrap_content"

  android:padding="5dp">

  <ImageView

  android:id="@+id/iv"

  android:layout_width="90dp"

  android:layout_height="90dp"

  android:scaleType="centerCrop"

  android:background="#000"></ImageView>

  <LinearLayout

  android:layout_width="match_parent"

  android:layout_height="wrap_content"

  android:orientation="vertical"

  android:padding="5dp">

  <TextView

  android:id="@+id/tv_title"

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:text="hello"

  android:textSize="20sp"

  android:textColor="@color/colorAccent"></TextView>

  <TextView

  android:id="@+id/tv_content"

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:text="2020-4-20"

  android:textSize="14sp"

  android:layout_marginTop="10dp"></TextView>

  </LinearLayout> </LinearLayout>

 实 验 结 果 及 分 析

 (对实验结果进行分析、总结实验心得体会以及改进建议)

 运行截图:

  教 师 评 语

  (教师对该生的实验准备、实验步骤、实验结果分析以及实验态度给出综合评价)

 教师签名:

  年

  月

  日

 实验五 实验名称 对话框的使用

 指导老师 李俊锋 实验教室

 实验时间

 实验成绩

 实 验 目 的 (给出本次实验要求掌握的知识点、技能等)

 1. 掌握 AlertDialog 控件的使用方法; 2. 掌握对话框按钮监听器的使用方法; 3. 能够熟练应用各种布局管理器和控件进行界面设计。

 实 验 环 境 (列出本次实验所使用的平台、器材和相关软件等)

 1. 部署有 Android Studio 和 Android SDK 的主机; 2. 建议在机房的 HelloWorld 例子上完成。

  实 验 准 备

 ( 硬件相关实验给出本实验实验原理;软件相关实验给出本实验涉及的相关知识点 )

 1.在 layout 文件夹的布局文件 activity_main.xml 中设计如下界面 (快速注册和忘记密码为两个 TextView)

 。

 2.用户单击图 1 中的 “快速注册”,弹出如图 2 的对话框(对话框中确定和取消按钮暂不需事件处理):

 3.用户单击图 1 中的 “退出”按钮,弹出如图 3 的对话框(点击对话框上的“确定”按钮退出当前程序,点击对话框上的“取消”返回图 1 的状态):

 实 验 内 容 及 实 验 步 骤

  ( 给出实验内容具体描述;硬件相关实验给出实验步骤和实验原始记录;软件相关实验给出程序清单、调试过程出现的问题以及解决方法、运行结果等)

 (1)以下是 drawable 文件,需复制到 drawable 文件夹。

  qq.jpg:qq 头像图片  ......  shape_edit_normal.xml:编辑框没有获取焦点时的获边框 (2)部分程序代码:

 MainActivity.java: public class MainActivity extends AppCompatActivity {

  private TextView tv_quickReg;

  private Button btn_exit;

  @Override

  protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_main);

  //tv_quickReg 是快速注册文本框的 id ; login 是弹出的快速注册对话框的布局文件名

 tv_quickReg = findViewById(R.id.tv_quickReg);

  tv_quickReg.setOnClickListener(new View.OnClickListener() {

  @Override

  public void onClick(View v) {

 TableLayout loginForm = (TableLayout) getLayoutInflater().inflate(R.layout.login, null);

  AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);

  builder.setIcon(R.drawable.hat)

  .setTitle(R.string.quickreg)

  .setView(loginForm)

  .setNegativeButton(" 取消", null)

  .setPositiveButton(" 确定", null)

  .create().show();}});

  //btn_exit 是退出按钮的 id

  btn_exit = findViewById(R.id.btn_exit);

  btn_exit.setOnClickListener(new View.OnClickListener() {

  @Override

  public void onClick(View v) {

  AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);

  builder.setIcon(R.drawable.alert)

  .setTitle(" 退出?")

  .setMessage(" 确定要退出吗?")

  .setNegativeButton(" 取消", null)

  .setPositiveButton(" 确定", new DialogInterface.OnClickListener() {

  @Override

  public void onClick(DialogInterface dialog, int which) {

  finish(); }}).create().show();}});}}

 实 验 内 容 及 实 验 步 骤

  login.xml:

 <TableRow>

  <TextView

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:text=" 邮箱:"

  android:textColor="@color/colorAccent"

  android:layout_marginRight="15dp"/>

  <EditText

  android:layout_width="250dp"

  android:layout_height="wrap_content"

  android:background="@drawable/editext_selector"

  android:inputType="textEmailAddress"/>

  </TableRow>

  <TableRow

  android:layout_marginTop="15dp">

  <TextView

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:text=" 密码:"

  android:textSize="18sp"

  android:textColor="@color/colorAccent"

  android:layout_marginRight="15dp"/>

  <EditText

  android:layout_width="250dp"

  android:layout_height="wrap_content"

  android:background="@drawable/editext_selector"

  android:inputType="textPassword"/>

  </TableRow> activity_main.xml

 <RelativeLayout><ImageView

  android:id="@+id/img"

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:src="@drawable/qq"></ImageView>

 <EditText

  android:id="@+id/ev_1"

  android:layout_width="match_parent"

  android:layout_height="wrap_content"

  android:hint=" 输入用户名"

  android:background="@drawable/editext_selector"

  android:layout_toRightOf="@id/tv_1"

 android:inputType="text"

  android:layout_marginLeft="10dp"></EditText></RelativeLayout>

  实 验 步 骤

 <RelativeLayout>

  <EditText

  android:id="@+id/ev_2"

  android:layout_width="match_parent"

  android:layout_height="wrap_content"

  android:background="@drawable/editext_selector"

  android:layout_toRightOf="@id/tv_2"

  android:inputType="textPassword"

  android:layout_marginLeft="10dp"></EditText> </RelativeLayout> <LinearLayout>

  <TextView

  android:id="@+id/tv_quickReg"

  android:layout_width="0dp"

  android:layout_height="wrap_content"

  android:layout_weight="1"

  android:text=" 快速注册"

  android:textSize="18sp"

  android:textColor="@color/colorBlue"

  android:gravity="center">

  </TextView></LinearLayout> <LinearLayout

  android:layout_width="match_parent"

  android:layout_height="wrap_content"

  android:orientation="horizontal"

  android:layout_marginTop="15dp"> <Button

  android:id="@+id/btn_exit"

  android:layout_width="0dp"

  android:layout_height="wrap_content"

  android:layout_weight="1"

  android:text=" 退出"></Button>

  <Button

  android:layout_width="0dp"

  android:layout_height="wrap_content"

  android:layout_weight="1"

  android:text=" 登录"

  ></Button> </LinearLayout>

 实 验 结 果 及 分 析

 (对实验结果进行分析、总结实验心得体会以及改进建议)

 运行截图:

 教 师 评 语

  (教师对该生的实验准备、实验步骤、实验结果分析以及实验态度给出综合评价)

 教师签名:

  年

  月

  日

 实验六 实验名称 事件处理

 指导老师 李俊锋 实验教室

 实验时间

 实验成绩

 实 验 目 的 (给出本次实验要求掌握的知识点、技能等)

 1. 掌握基于监听的事件处理机制,根据需求能够编写相应的事件处理程序。

 2. 能够熟练应用各种布局管理器和控件进行界面设计

 实 验 环 境 (列出本次实验所使用的平台、器材和相关软件等)

 1. 部署有 Android Studio 和 Android SDK 的主机; 2. 建议在机房的 HelloWorld 例子上完成。

  实 验 准 备

 ( 硬件相关实验给出本实验实验原理;软件相关实验给出本实验涉及的相关知识点 )

 设计一个显示用户触摸持续时间的小程序,在 layout 文件夹的布局文件activity_main.xml 中设计如下界面(2 个 TextView、1 个 EditText 和 1 个 ImageView),触摸 ImageView,在 TextView 中显示触摸时间。

 实 验 内 容 及 实 验 步 骤

  ( 给出实验内容具体描述;硬件相关实验给出实验步骤和实验原始记录;软件相关实验给出程序清单、调试过程出现的问题以及解决方法、运行结果等)

 (1)以下是 drawable 文件,需复制到 drawable 文件夹。

  background.jpg:ImageView 加载显示的图片 (2)部分程序代码

 MainActivity.java:

 public class MainActivity extends AppCompatActivity {

  /*public final long getDownTime()

  public final long getEventTime()

  public final int getAction()*/

  private ImageView img;

  private EditText et_1;

  public static final int ACTION_UP

 = 1;

  public static final int ACTION_DOWN

 = 0;

 @Override

  protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_main);

  img=findViewById(R.id.img);

  et_1=findViewById(R.id.et_1);

  img.setOnTouchListener(new View.OnTouchListener() {

  @Override

  public boolean onTouch(View v, MotionEvent event) {

  long start=event.getDownTime();

  long end=event.getEventTime();

  if(event.getAction()==ACTION_UP){

  et_1.setText((end-start)+"");

  }

  return true;

  }

  });

 }}

 实 验 内 容 及 实 验 步 骤

  (续表)

 activity_main.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

  android:layout_width="match_parent"

  android:layout_height="match_parent"

  android:orientation="vertical"

  android:paddingTop="5dp">

 <LinearLayout

 android:layout_width="match_parent"

 android:layout_height="wrap_content"

 android:orientation="horizontal"

 android:layout_marginLeft="10dp"

 android:paddingRight="80dp">

 <TextView

 android:layout_width="wrap_content"

 android:layout_height="wrap_content"

 android:text=" 触屏持续时间:"

 android:textSize="20sp"

 android:textColor="@color/colorBlack"></TextView>

 <EditText

 android:id="@+id/et_1"

 android:layout_width="120dp"

 android:layout_height="wrap_content"

 android:layout_marginLeft="10dp"

 android:paddingBottom="2dp"

 android:inputType="number"

 android:background="@drawable/shape_edit"></EditText>

 <TextView

 android:layout_width="wrap_content"

 android:layout_height="wrap_content"

 android:layout_marginLeft="5dp"

 android:text=" 毫秒"

 android:textSize="20sp"

 android:textColor="@color/colorBlack"></TextView>

 </LinearLayout>

  <ImageView

  android:id="@+id/img"

  android:layout_width="match_parent"

  android:layout_height="match_parent"

  android:src="@drawable/background"

  android:scaleType="fitXY"

  android:layout_marginTop="10dp"></ImageView> </LinearLayout>

 实 验 结 果 及 分 析

 (对实验结果进行分析、总结实验心得体会以及改进建议)

 运行截图:

 教 师 评 语

  (教师对该生的实验准备、实验步骤、实验结果分析以及实验态度给出综合评价)

 教师签名:

  年

  月

  日

 实验七 实验名称 使用 t Intent 在 在 y Activity 间传输数据

 指导老师 李俊锋 实验教室

 实验时间

 实验成绩

 实 验 目 的 (给出本次实验要求掌握的知识点、技能等)

 1. 理解 Activity 组件的功能与作用; 2. 掌握使用 Intent 在多个 Activity 组件间传输数据的方法; 3. 掌握在 AndroidManifest.xml 中配置 Activity 组件的方法。

 实 验 环 境 (列出本次实验所使用的平台、器材和相关软件等)

 1. 部署有 Android Studio 和 Android SDK 的主机; 2. 建议在机房的 HelloWorld 例子上完成。

  实 验 准 备 ( 硬件相关实验给出本实验实验原理;软件相关实验给出本实验涉及的相关知识点 )

 1、 完成一个体重计算器的应用程序开发。图 1 为该应用的首界面(即主 Activity),用户可选择性别和输入身高值,点击“计算”按钮后启动图 2 所示的界面(即第二个Activity)。可以通过 Intent 携带性别、身高数据到第二个 Activity,然后计算出体重并把三个数据显示到三个 TextView 中即可。

  图 1

  图 2

 体重计算公式:

 男性标准体重(单位:公斤)为:(身高(单位:厘米)-80)×0.7; 女性标准体重(单位:公斤)为:(身高(单位:厘米)-70)×0.6。

 实 验 内 容 及 实 验 步 骤

  ( 给出实验内容具体描述;硬件相关实验给出实验步骤和实验原始记录;软件相关实验给出程序清单、调试过程出现的问题以及解决方法、运行结果等)

 部分程序代码:

 MainActivity.java: public class MainActivity extends AppCompatActivity {

  @Override

  protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_main);

 private Button btn=findViewById(R.id.btn);

  btn.setOnClickListener(new View.OnClickListener() {

  @Override

  public void onClick(View v) {

  RadioButton male=findViewById(R.id.rb_1);

  EditText hei=findViewById(R.id.et_1);

  String gender=male.isChecked()?" 男":" 女";

  int height=Integer.parseInt(hei.getText().toString());

  Bundle bundle=new Bundle();

  bundle.putString("gender",gender);

  bundle.putInt("height",height);

  Intent intent=new Intent(MainActivity.this,InfoActivity.class);

  intent.putExtras(bundle);

  startActivity(intent);}});}} InfoActivity.java: public class InfoActivity extends AppCompatActivity {

  @Override

  protected void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_info);

  Intent intent=getIntent();

  Bundle bundle=intent.getExtras();

  String gender=bundle.getString("gender");

  int height=bundle.getInt("height");

  double weight=0.0;

  TextView sex=findViewById(R.id.sex);

  TextView hei=findViewById(R.id.hei);

  TextView wei=findViewById(R.id.wei);

  sex.setText(" 你是一位"+gender+" 性");

  hei.setText(" 你的身高是"+height+" 厘米");

  if(gender==" 男"){ weight=(height-80.0)*0.7; }

  else weight=(height-70.0)*0.6;

  wei.setText(" 你的标准体重是"+String.format("%.1f",weight)+" 公斤"); }}

 实 验 内 容 及 实 验 步 骤

  (续表)

 Activity_main.xml: <LinearLayout>

  <TextView

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:text=" 计算标准体重"

  android:textSize="25sp"/>

  <LinearLayout>

  <TextView

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:text=" 性别:"

  android:layout_gravity="center"

  android:textSize="20sp"></TextView>

  <RadioGroup

  android:layout_width="wrap_content"

  android:layout_height="wrap_content"

  android:orientation="horizontal"

  android:layout_marginLeft="10dp">

  <RadioButton>......</RadioButton></RadioGroup>

  </LinearLayout>

  <LinearLayout>

  <TextView> ......

  android:text="cm"

  android:textSize="20sp"></Text...

热门推荐
  • 党建工作存问题及整改

    党建工作存在问题及整改台账党建工作存在问题及整改台账基层党建工作主要是把基层党组织的工作重点放到凝聚群众共同奋斗上来,坚持基层党组织的领导核心、政治核心地位不动摇,依照《中国共产党章程》的规定,充分履

  • 在市委全体会议上报告

    同志们:这次全会的主要任务是:以习近平新时代中国特色社会主义思想为指导,学习贯彻党的十九大和十九届二中、三中、四中、五中、六中全会精神,贯彻落实习近平总书记考察xx重要讲话和重要指示批示精神,按照xx

  • 关于对评议反馈意见整

    关于对评议反馈意见整改落实情况的报告──X年X月X日在县X届人大常委会第X次会议上县文化和旅游局局长XXX主任、各位副主任、各位委员:根据《县人大常委会X年工作评议实施方案》要求,我局针对评议反馈意见

  • 法治建设督查整改报告3

    法治建设督查整改报告3篇法治建设督查整改报告    顺利开展,让群众知晓每一笔钱支出。设定每月1日为村务公开 民主理财议事日,逢节假日顺延,确保做到村务开展合法 合理,财务支出公开

  • 2022年领导干部述学报

    作者原创,不允许二次传播,一经发现收回会员权益,追究法律责任!述学报告今年以来,我认真学习党的十八届六中全会、党的十九大精神和习近平新时代中国特色社会主义思想,学习马列主义基本理论,学习政法业务和经济

  • 2022年关于上半年预算

    主任、副主任、各位委员:我受市人民政府委托,向会议报告2021年上半年预算执行情况,请予审议。一、上半年预算执行情况上半年,在市委的正确领导下,在市人大及其常委会的监督支持下,全市各级各部门坚持以习近

  • 关于省委巡视组巡视整

    根据省委统一部署,XXXX年X月X日至X月X日,省委第十五巡视组对XX市开展了脱贫攻坚巡视“回头看”。XXXX年X月XX日,省委巡视组向XX市委反馈了巡视意见。按照党务公开原则和巡视工作有关要求,现将

  • 2022巡视反馈意见整改

    巡视反馈意见整改专题民主生活会对照检查按照《中共XX省纪委机关中共XX省委组织部关于召开中央巡视整改反馈意见整改落实专题民主生活会的通知》要求,我深入学习领会习近平总书记关于巡视工作的重要讲话精神,认