zoukankan      html  css  js  c++  java
  • 学号 20175313 《Android程序设计》实验报告

    一、实验内容

    (1)Android Stuidio的安装测试

    参考http://www.cnblogs.com/rocedu/p/6371315.html#SECANDROID,安装 Android Stuidio

    • 完成Hello World, 要求修改res目录中的内容,Hello World后要显示自己的学号,自己学号前后一名同学的学号,提交代码运行截图和码云Git链接,截图没有学号要扣分
    • 学习Android Stuidio调试应用程序

    (2)Activity测试

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

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

    (3)UI测试

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

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

    (4)布局测试

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

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

    (5)事件处理测试

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

    • 构建项目,运行教材相关代码
    • 提交代码运行截图和码云Git链接,截图要有学号水印,否则会扣分

    二、实验步骤

    本次实验就是一个学习的过程,其实实验步骤指导书中都已经有了详细的说明,所以我就对本次实验所学到的内容进行小结。

    (1)Android Stuidio的安装测试

    调试

    • android.util.Log类用于记录日志消息。
    • Log类有以下几种方法:
      • d(debug)
      • i(info)
      • v(verbose)
      • w(warning)
      • e(error)
      • wtf(whst a terrible failure)

    (2)Activity测试

    • 启动另一个活动
    startActivity(intent)
    
    • 给调用的活动传递额外的信息
    intent.putExtra("message","Message from first screen")
    
    • 调用getIntent方法并且通过getStringExtra方法获取一条消息
    Intent intent = getIntent();
    String Message = intent.getStringExtra("message");
    

    (3)UI测试

    • Button
     <Button
            android:id="@+id/saveButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="100dp"
            android:layout_centerHorizontal="true"
            android:text="Speak"/>
    
    • textView
    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello World!
    20175313
    20175312
    20175314"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    
    • Toast:android.wedget.Toast类是创建Toast的模板
    • 调用构造方法创建Toast
    public Toast(android.content.Context context)
    
    • 调用Toast类的两个静态方法创建Toast的模板
    public static Toast makeText(android.content.Context context,int resourceId,int duration)
    
    public static Toast makeText(android.content.Context context,java.lang.CharSequence text,int duration)
    
    • 在活动类中创建并显示show
    Toast.makeText(this,"Downloading…",Toast.LENGTH_LONG).show();
    

    (4)布局测试

    • RelativeLayout中的所有子视图都可以相对于彼此或者相对于父视图来定位。

    (5)事件处理测试

    • 想要让程序响应某个事件,需要为该事件编写一个监听器,即接口的实现。
    • 接口的实现有两种方法:

    方法一:使用匿名类实现接口

    button.setOnClickListener(new OnClickListener(){//与接口有关的匿名类
                @Override
                public void onClick(View v){
                Toast.makeText(MainActivity.this, "20175313", Toast.LENGTH_LONG).show();
            }
            });
    

    方法二:在主类中实现接口,并重写方法

    public class MainActivity extends AppCompatActivity implements View.OnTouchListener {……}
    
    public boolean onTouch(View arg0, MotionEvent event){
            Intent intent = new Intent(this,ThirdActivity.class);
            intent.putExtra("message","20175313");
            startActivity(intent);
            return true;
        }
    

    三、实验结果截图

    (1)Android Stuidio的安装测试

    (2)Activity测试

    (3)UI测试

    (4)布局测试

    (5)事件处理测试

    四、实验过程中遇到的问题及其解决方法

    • 问题:运行程序后,显示出来的视图界面,只出现在我虚拟手机的左上方
    • 解决方法:百度上搜了修改Android配置的方法也没能解决,最后只能修改我电脑的分辨率(将推荐的150%改为100%)来解决问题。

    五、心得体会

    • 通过本次实验我认识到了,有个强大的C盘真的很重要!
    • 科技真的很强大,拓宽了我的视野。

    六、码云链接

    七、参考资料

  • 相关阅读:
    Flutter 导航栏上添加搜索按钮
    tabController保活
    nav 选项卡
    flutter 毛玻璃
    [题解]CodeForces878 D
    [题解]CodeForces878C Tournament
    [题解]NOIP2012
    bzoj1070题解
    bzoj1061题解
    bzoj1059题解
  • 原文地址:https://www.cnblogs.com/xiannvyeye/p/10884828.html
Copyright © 2011-2022 走看看