实验四 《Android开发基础》 20175301李锦然实验报告

实验四 《Android开发基础》实验报告


课程:Java程序设计 班级:1753班 姓名:李锦然 学号:20175301
指导教师:娄嘉鹏 实验日期:2019年5月14日
实验时间:--- 实验序号:实验四
实验名称:Android开发基础

实验四 《Android开发基础》实验报告

实验目的与要求:

参考Android开发简易教程
完成云班课中的检查点,也可以先完成实验报告,直接提交。
注意不能只有截图,要有知识点,原理,遇到的问题和解决过程等说明。
实验报告中一个检查点要有多张截图。
发表实验报告博客,标题“学期(如2018-2019-2) 学号(如20175301) 实验四《Android开发基础》实验报告”

实验步骤:

1.Android Stuidio的安装测试: 参考《Java和Android开发学习指南(第二版)(EPUBIT,Java for Android 2nd)》第二十四章

  • 参考http://www.cnblogs.com/rocedu/p/6371315.html#SECANDROID,安装 Android Stuidio
  • 完成Hello World, 要求修改res目录中的内容,Hello World后要显示自己的学号,自己学号前后一名同学的学号,提交代码运行截图和码云Git链接,截图没有学号要扣分
  • 学习Android Stuidio调试应用程序

按照教学安装Andoid Stuidio
1268747-20190514180130719-862555155.jpg

新建项目,创造虚拟机并且完成HelloWorld后加学号
1268747-20190514181027349-1160230164.jpg
1268747-20190514181233639-221985623.jpg

修改的res内容与码云Git链接 关键在于找到android:text
1268747-20190514181542905-1982082785.jpg
1268747-20190514181550158-885061343.jpg
1268747-20190514182034623-1705086956.jpg
https://gitee.com/ShengHuoZaiDaXue/20175301/tree/master/20175301/EXP4


2.Activity测试: 参考《Java和Android开发学习指南(第二版)(EPUBIT,Java for Android 2nd)》第二十五章

  • 构建项目,运行教材相关代码
  • 创建 ThirdActivity, 在ThirdActivity中显示自己的学号,修改代码让MainActivity启动ThirdActivity
  • 提交代码运行截图和码云Git链接,截图要有学号水印,否则会扣分

最终效果展示
1268747-20190517073202067-628732539.jpg
1268747-20190517073151842-1799663697.jpg
主要改动是在main中加入了intend对象可以延伸出下一个软件
码云链接:
1268747-20190517073748735-222792288.jpg
https://gitee.com/ShengHuoZaiDaXue/20175301/tree/master/20175301/EXP4


3.UI测试: 参考《Java和Android开发学习指南(第二版)(EPUBIT,Java for Android 2nd)》第二十六章

  • 构建项目,运行教材相关代码
  • 修改代码让Toast消息中显示自己的学号信息
  • 提交代码运行截图和码云Git链接,截图要有学号水印,否则会扣分
在MainActivity.java中操作
1.import android.widget.Toast;引入方法
2.Toast.makeText(MainActivity.this, "我就是县长!5301, Toast.LENGTH_SHORT).show();快速调用

完整代码

package com.example.myapplication;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends Activity {
    private Button button1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toast.makeText(MainActivity.this, "我就是县长!5301", Toast.LENGTH_SHORT).show();
        button1 = (Button) findViewById(R.id.button1);
        button1.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(
                        MainActivity.this, ThirdActivity.class); 
                startActivity(intent);
            }

        })
        ;}
}

运行结果
1268747-20190517102409338-1895578429.jpg
码云链接:
https://gitee.com/ShengHuoZaiDaXue/20175301/tree/master/20175301/EXP4


4.布局测试: 参考《Java和Android开发学习指南(第二版)(EPUBIT,Java for Android 2nd)》第二十七章

  • 构建项目,运行教材相关代码
  • 修改布局让P290页的界面与教材不同
  • 提交代码运行截图和码云Git链接,截图要有学号水印,否则会扣分
    运行教材相关代码,修改布局
    1268747-20190517111800069-1892262262.jpg
    1268747-20190517111423344-120587875.jpg
    代码:
<?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">

    <Button
        android:id="@+id/button1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="启动Thirdactivity"
        tools:ignore="MissingConstraints" />


    <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:paddingLeft="2dp"
        android:paddingRight="2dp">
        <Button
            android:id="@+id/cancelButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="20175301"
            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:layout_below="@+id/cancelButton"
            android:layout_alignStart="@+id/cancelButton"
            android:layout_alignLeft="@+id/cancelButton"
            android:layout_marginStart="7dp"
            android:layout_marginLeft="7dp"
            android:layout_marginTop="269dp"
            android:text="李锦然" />
        <ImageView
            android:layout_width="150dp"
            android:layout_height="150dp"
            android:layout_marginTop="45dp"
            android:padding="4dp"
            android:src="@android:drawable/presence_audio_away"
            android:id="@+id/imageView"
            android:layout_below="@+id/saveButton"
            android:background="@android:color/white"
            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/holo_blue_dark"
            android:orientation="horizontal" >
            <Button
                android:id="@+id/filterButton"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:text="Open" />
            <Button
                android:id="@+id/shareButton"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:text="Share" />
            <Button
                android:id="@+id/deleteButton"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:text="Delete" />
        </LinearLayout>
    </RelativeLayout>
    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="132dp"
        android:layout_marginRight="132dp"
        android:text="Hello!20175301"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:text="Hello World!20175301" />

</android.support.constraint.ConstraintLayout>

码云链接:
https://gitee.com/ShengHuoZaiDaXue/20175301/tree/master/20175301/EXP4


5.事件处理测试: 参考《Java和Android开发学习指南(第二版)(EPUBIT,Java for Android 2nd)》第二十八章

  • 构建项目,运行教材相关代码
  • 提交代码运行截图和码云Git链接,截图要有学号水印,否则会扣分
    构建项目,运行教材相关代码
    1268747-20190517113609881-286570911.jpg
    1268747-20190517113406627-1950311582.jpg
    1268747-20190517113414562-1198206720.jpg
    码云链接:
    https://gitee.com/ShengHuoZaiDaXue/20175301/tree/master/20175301/EXP4

出现问题与解决方法

  1. ACTIVITY测试时,总是无法正常转入thirdactivity会出现error并闪退
    解决方法:改写intend并加入按键使用按键驱动
    2 .布局测试时,没用代码,直接用DESIGN调试导致图像位置不对(会莫名其妙的和其他东西连上)
    解决方法:找layout_width和high来手改

参考资料:
1.《Java和Android开发学习指南(第二版)》

转载于:https://www.cnblogs.com/lijinran/p/10863427.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值