20175212童皓桢 实验四 Android程序设计
20175212童皓桢 实验四 Android程序设计
实验内容
- 参考《Java和Android开发学习指南(第二版)(EPUBIT,Java for Android 2nd)》并完成相关学习
实验步骤
一、Android Stuidio的安装测试
任务一要求:
- 参考http://www.cnblogs.com/rocedu/p/6371315.html#SECANDROID,安装Android Stuidio
- 完成Hello World, 要求修改res目录中的内容,Hello World后要显示自己的学号,自己学号前后一名同学的学号
- 学习Android Stuidio调试应用程序
实验过程:
- 将MainActivity.java中,选择text界面,将
android:text="Hello World!"修改为
android:text="Hello World20175212 20175211 20175213!"

- 将MainActivity.java中,选择design图形界面,选中中间的文本框进行编辑,输入
"Hello World20175212 20175211 20175213!"

- 运行结果:

二、Activity测试
任务二要求:
- 构建项目,运行教材相关代码
- 创建 ThirdActivity, 在ThirdActivity中显示自己的学号,修改代码让MainActivity启动ThirdActivity
- 提交代码运行截图和码云Git链接
实验过程
- 在
MainActivity相同的目录下创建ThirdActivity项目 - 按照修改
MainActivity中相关代码 - 修改在
layout中activity_third.xml文件,具体是
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="20175212童皓桢" />
- MainActivity.java
package com.example.helloworld;
import android.content.Intent;
import android.support.v7.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);
Intent intent = new Intent(this,ThirdActivity.class);
startActivity(intent);
}
}
- Activity_third.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=".ThirdActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="20175212童皓桢" />
</android.support.constraint.ConstraintLayout>
运行结果:

三、UI测试
任务三要求:
- 构建项目,运行教材相关代码
- 修改代码让Toast消息中显示自己的学号信息
- 提交代码运行截图和码云Git链接
- MainActivity.java
package com.example.helloworld;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toast toast=Toast.makeText(MainActivity.this, "20175212童皓桢", Toast.LENGTH_LONG);
toast.show();
}
}
运行结果:

四、布局测试
任务四要求:
- 构建项目,运行教材相关代码
- 修改布局让P290页的界面与教材不同
- 提交代码运行截图和码云Git链接,截图要有学号水印
- activity_main.xml
<RelativeLayout
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"
android:paddingLeft="2dp"
android:paddingRight="2dp">
<Button
android:id="@+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="20175212"
android:layout_marginTop="70dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<Button
android: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" />
<ImageView
android: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" />
<LinearLayout
android: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" >
<Button
android:id="@+id/filterButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Filter" />
<Button
android:id="@+id/shareButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
and
运行结果:

五、事件处理测试
- 构建项目,运行教材相关代码
- 提交代码运行截图和码云Git链接,截图要有学号水印
- activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context=".MainActivity">
<AnalogClock
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="90dp"
android:id="@+id/analogClock1"
android:onClick="changeColor" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="20175212 童皓桢"
android:layout_marginLeft="60dp"
android:layout_marginTop="300dp"
android:textSize="16dp"/>
</RelativeLayout>
运行结果:

实验中遇到的问题
- 问题一:Android Studio中出现Java未识别文件,并且无法正常编译运行。(类名前为红J)

- 解决办法一:在左边目录中找到build.gradle文件,点击Sync Project with Gradle File。或者参考https://www.cnblogs.com/kissfu/p/6093335.html添加代码,即可解决。

参考博客
https://www.cnblogs.com/kissfu/p/6093335.html
20175212童皓桢 实验四 Android程序设计的更多相关文章
- 20175212童皓桢 实验三敏捷开发与XP实践实验报告
20175212童皓桢 实验三敏捷开发与XP实践实验报告 实验内容 XP基础 XP核心实践 相关工具 实验步骤 一.Code菜单功能的研究 Move Line/statement Down/Up:将某 ...
- 20175212童皓桢 Java实验二-面向对象程序设计实验报告
20175212童皓桢 Java实验二-面向对象程序设计实验报告 实验内容 初步掌握单元测试和TDD 理解并掌握面向对象三要素:封装.继承.多态 初步掌握UML建模 熟悉S.O.L.I.D原则 了解设 ...
- 20175212童皓桢 《Java程序设计》第11周学习总结
20175212童皓桢 <Java程序设计>第11周学习总结 教材学习内容总结 一.URL类 1.一个URL对象通常包含最基本的三部分信息:协议.地址.资源 2.构造方法: public ...
- 学号 20175212童皓桢 《Java程序设计》第8周学习总结
学号 20175212童皓桢 <Java程序设计>第8周学习总结 教材学习内容总结 泛型 class People<E> 其中People是泛型类的名称,E是其中的泛型,也就是 ...
- 20175212童皓桢 《Java程序设计》第六周学习总结
20175212童皓桢 <Java程序设计>第六周学习总结 教材学习内容总结 第七章 内部类与异常类 1.内部类 Java支持在一个类中定义另一个类,这样的类称作内部类,包含内部类的类称为 ...
- 实验四 Android程序设计 实验报告
实验四 Android程序设计 实验报告 目录 代码托管地址 Android程序设计-1 Android程序设计-2 Android程序设计-3 Android程序设计-4 Android程序设计-5 ...
- 第十四周实验报告:实验四 Android程序设计
20162317袁逸灏 第十四周实验报告:实验四 Android程序设计 实验内容 Android Studio 实验要求 学会使用Android Studio 学习 活动 以及相关知识内容 学习 U ...
- 20175212童皓桢 在IDEA中以TDD的方式对String类和Arrays类进行学习
20175212童皓桢 在IDEA中以TDD的方式对String类和Arrays类进行学习 要求 在IDEA中以TDD的方式对String类和Arrays类进行学习 测试相关方法的正常,错误和边界情况 ...
- 20165235实验四 Android程序设计
20165235实验四 Android程序设计 实验课程:JAVA编程设计 实验名称:Android开发 姓名:祁瑛 学号:20165235 实验时间:2018.05.16 指导老师:娄家鹏 Andr ...
随机推荐
- golang substring
在java下习惯了String.subString(start,end) 然后再golang继续敲substring木有了,看了下代码,也是原生支持的 但是百度发现有些人竟然把字符串转成字符数组再根据 ...
- postgres 常规操作杂记
分布式:1.扩容不方便(数据重分布)2.分布键变更很麻烦3.分布键选择(架构设计)谨慎4.跨库join性能差5.分布式事务性能差6.sql限制多,功能确实多7.应用改造成本巨大8.全局一致性时间点恢复 ...
- 103、Swarm如何管理存储数据?(Swarm10)
参考https://www.cnblogs.com/CloudMan6/p/8000906.html Service 的容器副本会 scale up/down ,会 failover,会在不同的主 ...
- 098、Swarm 如何实现 Failover (Swarm05)
参考https://www.cnblogs.com/CloudMan6/p/7898245.html 故障是在所难免的,容器可能崩溃,Docker Host 可能宕机,不过幸运的是,Swarm 已 ...
- 第二十三篇 jQuery 学习5 添加元素
jQuery 学习5 添加元素 同学们,这节课,使用jQuery动态添加元素,是很关键的一课,一般用在什么地方呢:别人发表一篇文章,你评论楼主的时候,总不能是提交表单,到后台的其他页面处理,然后再 ...
- react如何通过shouldComponentUpdate来减少重复渲染
转自:https://segmentfault.com/a/1190000016494335 在react开发中,经常会遇到组件重复渲染的问题,父组件一个state的变化,就会导致以该组件的所有子组件 ...
- VMware安装CentOS7_1511 mini版本
这次安装使用的是 CentOS7_1511_mini 如果没有点击下载 点击下载
- Storm项目开发纪要
1.POM引用storm-core和javax.servlet-api这两个组件,如果本地模式跑拓扑,要把<scope>provided</scope>去掉:如果远程发布运行, ...
- orcle_day02
第三章:单值函数 函数分为: 1.单值函数 1.字符函数 2.日期函数 3.转换函数 4.数字函数 2.分组函数(后面的章节再做学习) 哑表dual dual是一个虚拟表,用来构成select的语法规 ...
- 18、nginx优化
一.性能优化概述 基询imm能优化,那么在性能优化这一章,我们将分为如下几个方面做介绍 1.首先我们需要了解性能优化要考虑哪些方面. 2.然后我们需要了解性能优化必须要用到的压力测试工具ab. 3.最 ...