实验四 Android程序设计

实验目的

  • 一、Android Studio的安装测试

  • 二、Activity测试

  • 三、UI测试

  • 四、布局测试

  • 五、事件处理测试

实验内容及步骤

(一)Android Studio的安装测试

  • 安装Android Studio

成功安装后再进行Android SDK。

  • 修改res目录中的内容,hello world后要显示自己的学号,以及自己学号前后一名同学的学号

(二)Activity测试

  • 构建项目ThirdActivity

  • 创建ThirdActivity,在ThirdActivity中显示自己的学号,修改代码让MainActivity启动ThirdActivity
package com.example.xiang.thirdactivity;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.TextView;
public class MainActivity extends Activity implementsOnTouchListener {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);TextView tv = (TextView) findViewById(R.id.textView1);tv.setOnTouchListener(this);}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it
// is present.getMenuInflater().inflate(R.menu.menu_main, menu);return true;}@Overridepublic boolean onTouch(View arg0, MotionEvent event) {Intent intent = new Intent(this, ThirdActivity.class);intent.putExtra("message", "20165226");startActivity(intent);return true;}
}
  • 提交代码运行截图和码云Git链接,截图加学号水印

(三)UI测试

  • 构建项目MyApplication3,运行教材相关代码
  • 修改代码让Toast消息中显示自己的学号信息
    - MainActivity

    package MyApplication3.app.src.main.java.com.example.xiang.myapplication;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.content.Context;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.app.Activity;
    import android.util.AttributeSet;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.View;
    import android.widget.Button;
    import android.widget.Toast;
    public class MainActivity extends AppCompatActivity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Button btnshow1 = (Button) findViewById(R.id.btn1);btnshow1.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {Toast toast = Toast.makeText(MainActivity.this, "20165226", Toast.LENGTH_LONG);toast.show();}});}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it// is present.getMenuInflater().inflate(R.menu.menu_main, menu);return true;}
    }
    • activity_main.xml
    <?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.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"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="20165226"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintRight_toRightOf="parent"app:layout_constraintTop_toTopOf="parent" />
    </android.support.constraint.ConstraintLayout>
  • 结果

(四)布局测试

  • 构建项目,运行教材相关代码
  • 修改布局让P290页的界面与教材不同
    • activity_main.xml
    <RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:paddingLeft="2dp"android:paddingRight="2dp"><Buttonandroid:id="@+id/cancelButton"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="20165226"android:layout_marginTop="70dp"android:layout_alignParentTop="true"android:layout_centerHorizontal="true" /><Buttonandroid:id="@+id/saveButton"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="刘香杉"android:layout_below="@+id/cancelButton"android:layout_alignLeft="@+id/cancelButton"android:layout_alignStart="@+id/cancelButton"android:layout_marginTop="23dp" /><ImageViewandroid:layout_width="150dp"android:layout_height="150dp"android:layout_marginTop="45dp"android:padding="4dp"android:src="@android:drawable/ic_dialog_email"android:id="@+id/imageView"android:layout_below="@+id/saveButton"android:layout_centerHorizontal="true" /><LinearLayoutandroid:id="@+id/filter_button_container"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:gravity="center|bottom"android:background="@android:color/white"android:orientation="horizontal" ><Buttonandroid:id="@+id/filterButton"android:layout_width="wrap_content"android:layout_height="fill_parent"android:text="Filter" /><Buttonandroid:id="@+id/shareButton"android:layout_width="wrap_content"android:layout_height="fill_parent"android:text="Share" /><Buttonandroid:id="@+id/deleteButton"android:layout_width="wrap_content"android:layout_height="fill_parent"android:text="Delete" /></LinearLayout>
    </RelativeLayout>
  • 结果

(五)事件处理测试

  • 构建项目,运行教材相关代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:paddingBottom="150dp"android:paddingLeft="150dp"android:paddingRight="150dp"tools:context=".MainActivity"><AnalogClockandroid:id="@+id/analogClock1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentTop="true"android:layout_centerHorizontal="true"android:layout_marginTop="200dp"android:onClick="changeColor" />
</RelativeLayout>
  • 结果

遇到问题及解决方案

  • 问题1:下载gradle时,不能正常顺利下载,在一次次点击try again始终弹出design not successful

  • 问题1解决方案:外下,然后把gradle拖进相关文件,或者检查等待网络畅通。
  • 问题2:在运行时,因文件命名有误,build failed

  • 问题2解决方案:通过重命名文件为menu_main.xml,成功解决问题。

统计PSP(Personal Software Process)时间:

步骤 耗时 百分比
设计 90min 50%
代码实现 45 25%
测试 20 11%
分析总结 25 14%

实验小结

本次实验主要学会了下载安装Android Studio及其使用情况。Android Studio相对来说十分陌生,但他是建立在java基础之上,有Java搭建平台会好懂很多。在各种尝试下仍不能运行时,有些焦急,但在顺利解决问题之后,特别是显示出虚拟界面时,有小小的满足与成就。

转载于:https://www.cnblogs.com/musea/p/9037166.html

20165226 实验四 Android程序设计相关推荐

  1. 20155321 实验四 Android程序设计

    20155321 实验四 Android程序设计 安装Android studio成功 任务一:Android Stuidio的安装测试: 参考<Java和Android开发学习指南(第二版)( ...

  2. 20165235实验四 Android程序设计

    20165235实验四 Android程序设计 实验课程:JAVA编程设计 实验名称:Android开发 姓名:祁瑛 学号:20165235 实验时间:2018.05.16 指导老师:娄家鹏 Andr ...

  3. 实验四 Android程序设计

    实验四 Android程序设计 课程:Java程序设计 班级:1652 姓名:孔月 学号:20165208 指导教师:娄嘉鹏 实验日期:2018.5.14 实验名称:Android程序设计 实验要求: ...

  4. 20155330 实验四 Android程序设计

    20155330 实验四 Android程序设计 实验内容 1.基于Android Studio开发简单的Android应用并部署测试; 2.了解Android.组件.布局管理器的使用: 3.掌握An ...

  5. # 20155224 实验四 Android程序设计

    20155224 实验四 Android程序设计 任务一 Android Stuidio的安装测试: 参考<Java和Android开发学习指南(第二版)(EPUBIT,Java for And ...

  6. 20155314 2016-2017-2 《Java程序设计》实验四 Android程序设计

    20155314 2016-2017-2 <Java程序设计>实验四 Android程序设计 实验任务 基于Android Studio开发简单的Android应用并部署测试 了解Andr ...

  7. #20165323 Java实验四 Android程序设计

    一.实验报告封面 课程:Java程序设计 班级:1653班 姓名:杨金川 学号:20165323 指导教师:娄嘉鹏 实验日期:2018年5月14日 实验时间:13:45 - 15:25 实验序号:实验 ...

  8. 20155238 实验四 Android程序设计

    Android 安装Android Studio 按照教程依次完成安装步骤.安装所存的相应文件夹必须纯英文,不能出现特殊字符. 32位系统和64位系统是同一个安装文件.启动程序中32位与64位都有.根 ...

  9. 2018-2019-2 实验四 Android程序设计

    实验要求 参考Android开发简易教程 完成云班课中的检查点,也可以先完成实验报告,直接提交.注意不能只有截图,要有知识点,原理,遇到的问题和解决过程等说明.实验报告中一个检查点要有多张截图. 发表 ...

最新文章

  1. 数据分析pandas属性实现统计分析
  2. sqoop(数据迁移工具)-安装-学习
  3. K8S精华问答 | K8S和Openstack发展方向是怎样的?
  4. jenkins部署java项目之小白的笔记
  5. POCO C++ Libraies介绍及常见用法
  6. html5和html的区别是什么?学HTML5要不要学html?
  7. 异常Exception(Java)
  8. vue-devtools安装及使用
  9. phpwind升级php7,【原创文章】升级phpwind为https
  10. 2020 数据中心机房建设方案
  11. SIM800L模块发送短信
  12. 营销圈带你从微博推广角度看《延禧攻略》如何完美KO《如懿传》
  13. [开发笔记]-多线程
  14. 《通关!游戏设计之道(continue...)》
  15. 安装Matlab时用mathwork账户登陆时显示连接错误
  16. Python—re正则表达式
  17. 总计超5万星!GitHub上10个超级好玩的项目
  18. HCIE-CloudComputing学习笔记之一:FusionComuter-2020.12
  19. 微信公众号如何做好日常维护?
  20. 富文本编辑器simditor的使用

热门文章

  1. 给ListView视图添加行号
  2. centos6.5 x86_64安装rsyslog + loganalyzer
  3. ZH奶酪:Ubuntu 14.04配置LAMP(Linux、Apache、MySQL、PHP)
  4. GeoServer注意点
  5. 关于office2013无法登陆的问题(出现临时服务器问.。
  6. c#通过OleDb连接sybase 15.5
  7. linq To DataTable
  8. centos7 常用命令参考
  9. iOS核心动画 - CALayer
  10. 使用tornado让你的请求异步非阻塞