• 实验四 《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

    新建项目,创造虚拟机并且完成HelloWorld后加学号

    修改的res内容与码云Git链接 关键在于找到android:text



    https://gitee.com/ShengHuoZaiDaXue/20175301/tree/master/20175301/EXP4


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

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

    最终效果展示


    主要改动是在main中加入了intend对象可以延伸出下一个软件
    码云链接:

    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);
                }
    
            })
            ;}
    }
    

    运行结果

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


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

    • 构建项目,运行教材相关代码
    • 修改布局让P290页的界面与教材不同
    • 提交代码运行截图和码云Git链接,截图要有学号水印,否则会扣分
      运行教材相关代码,修改布局


      代码:
    <?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)》第二十八章


    出现问题与解决方法

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

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

  • 相关阅读:
    SVN更新的时候前面的子母的意思(A C D M G U R I)
    SQL总结(一)基本查询
    eclipse中如何打开工作空间里面已经有的项目
    java for循环的几种写法
    Eclipse自动生成作者、日期注释等功能设置
    linux任务计划及周期性任务计划
    进程管理工具使用
    Btrfs管理及应用
    LVM基本应用,扩展及缩减实现
    Linux-RAID
  • 原文地址:https://www.cnblogs.com/lijinran/p/10863427.html
Copyright © 2020-2023  润新知