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链接

    实验过程
  1. 在MainActivity相同的目录下创建ThirdActivity项目
  2. 按照修改MainActivity中相关代码
  3. 修改在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程序设计的更多相关文章

  1. 20175212童皓桢 实验三敏捷开发与XP实践实验报告

    20175212童皓桢 实验三敏捷开发与XP实践实验报告 实验内容 XP基础 XP核心实践 相关工具 实验步骤 一.Code菜单功能的研究 Move Line/statement Down/Up:将某 ...

  2. 20175212童皓桢 Java实验二-面向对象程序设计实验报告

    20175212童皓桢 Java实验二-面向对象程序设计实验报告 实验内容 初步掌握单元测试和TDD 理解并掌握面向对象三要素:封装.继承.多态 初步掌握UML建模 熟悉S.O.L.I.D原则 了解设 ...

  3. 20175212童皓桢 《Java程序设计》第11周学习总结

    20175212童皓桢 <Java程序设计>第11周学习总结 教材学习内容总结 一.URL类 1.一个URL对象通常包含最基本的三部分信息:协议.地址.资源 2.构造方法: public ...

  4. 学号 20175212童皓桢 《Java程序设计》第8周学习总结

    学号 20175212童皓桢 <Java程序设计>第8周学习总结 教材学习内容总结 泛型 class People<E> 其中People是泛型类的名称,E是其中的泛型,也就是 ...

  5. 20175212童皓桢 《Java程序设计》第六周学习总结

    20175212童皓桢 <Java程序设计>第六周学习总结 教材学习内容总结 第七章 内部类与异常类 1.内部类 Java支持在一个类中定义另一个类,这样的类称作内部类,包含内部类的类称为 ...

  6. 实验四 Android程序设计 实验报告

    实验四 Android程序设计 实验报告 目录 代码托管地址 Android程序设计-1 Android程序设计-2 Android程序设计-3 Android程序设计-4 Android程序设计-5 ...

  7. 第十四周实验报告:实验四 Android程序设计

    20162317袁逸灏 第十四周实验报告:实验四 Android程序设计 实验内容 Android Studio 实验要求 学会使用Android Studio 学习 活动 以及相关知识内容 学习 U ...

  8. 20175212童皓桢 在IDEA中以TDD的方式对String类和Arrays类进行学习

    20175212童皓桢 在IDEA中以TDD的方式对String类和Arrays类进行学习 要求 在IDEA中以TDD的方式对String类和Arrays类进行学习 测试相关方法的正常,错误和边界情况 ...

  9. 20165235实验四 Android程序设计

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

随机推荐

  1. mac下开启phpredis扩展

    下载 官网下载php合适的版本:http://pecl.php.net/package/redis 这里我的php版本:7.1.23,下载的phpredis版本:5.0.0 配置安装 解包.重命名 s ...

  2. C#中的编译为什么不叫Compile而叫build

    是因为Build包含了compile,build既compile了你自己的代码,又把你compile的Assembly和引用别人的Assembly放在一起buiid.

  3. python 中的 [:-1] 和 [::-1]

    1.案例解释 a='python' b=a[::-1] print(b) #nohtyp c=a[::-2] print(c) #nhy #从后往前数的话,最后一个位置为-1 d=a[:-1] #从位 ...

  4. sql limit i,n

    limit i,n; i:为查询结果的索引值(默认从0开始),当i=0时可省略i n:为查询结果返回的数量(也就是条数) 表示从第i+1条开始,取n条数据 limit n 等同于 limit 0,n ...

  5. TKmybatis和mybatisplus哪个好用

    文档连接 :http://baomidou.oschina.io/mybatis-plus-doc/#/?id=%E7%AE%80%E4%BB%8B https://gitee.com/hengboy ...

  6. 新增分区格式化时提示设备文件不存在:--- No such file or directory的处理方法

    [原文链接]:http://blog.itpub.net/28874898/viewspace-774249/ 在系统中的空余空间添加新的分区:   fdisk   /dev/sda (第一块硬盘上) ...

  7. SSD学习笔记

    目标检测算法——SSD:Single Shot MultiBox Detector,是一篇非常经典的目标检测算法,十分值得阅读和进行代码复现,其论文地址是:https://arxiv.org/abs/ ...

  8. mybaites 入门到精通

    这个mybatis教程也不错:http://limingnihao.iteye.com/blog/781671 MyBatis 目录(?)[-] mybatis实战教程mybatis in actio ...

  9. constant read 和 current read

    来自网络,并且在本机实验完成: onsistent read :我的理解,就是通过scn来读取.  读取的过程中要保证 scn是一致的.举个例子,一个SELECT 语句在SCN=100的时刻开始读取一 ...

  10. 浏览器自动将参数中的url转码问题

    遇到一个问题, 开始的url如下: http://localhost:6666/pages/wxpay.html? code_url=weixin://wxpay/biz 请求转发到谷歌浏览器打开后变 ...