从零开始学Android开发期末复习重点

news/2024/10/18 7:47:41/

目录

  • 前言
  • 作业1
  • 作业2
  • 作业3
  • 作业4
  • 作业5
  • 作业6

前言

物联网应用技术课程期末复习重点——学习通作业:

操作系统:Ubuntu22.04

作业1

  1. 简述Android系统架构。
Android 的系统架构和它的操作系统一样,采用了分层的架构.
分为四个层,从高到低分别是程序层、应用程序框架层和Linux核心层。
  1. Android常用的组件有哪些?
Activity、Intent、BroadcastReceiver、ContentProvider、Service
  1. 简述一个Android项目的创建过程。
(1)启动Eclipse,依选择File|New|Project 命令,Eclipse将弹出New Project对话框。(2)单击 Android下拉箭头,选择 Android Application Project选项,然后单击Next按钮,
跳转到 New Android App 对话框。(3)在New Android App 对话框中的 Application Name 文本框中输入应用名称 HelloAndroid,
然后单击Next 按钮,切换到 Configure Launcher Icon 界面。(4)单击 Configure Launcher Icon 界面的 Choose按钮,可以在弹出的对话框中选择任意图标,
作为应用程序图标。然后单击 Next 按钮,切换到 Create Activity 界面。(5)在Create Activity面中,勾选Create Activity的单选框,创建项目的同时,
也会自动创建 Activity。然后单击Next 按钮,切换到New Blank Activity界面。(6)在New Blank Activity界面,会自动生成Activity的名称和布局文件的名称。
可以使用默认名称,也可以修改为其他名称。然后单击 Finish 按钮,完成项目创建。
  1. 简述android应用程序结构图。
    1.src:存放程序的源代码。 2.gen:系统自动生成,无需手动修改。最重要的就是R.java文件,保存了程序中所在用到的所有控件和资源ID。3.assets:存放不进行编译加工的原生文件,这里的资源文件不会在Rjava自动生成ID。4.drawable-hdpi:存放高分辨率的资源图片。5.drawable-ldpi:存放低分辨率的资源图片。6.drawable-mdpi:存放中等分辨率的资源图片。7.drawable-xhdpi:存放超高分辨率的资源图片,从Android 2.2(APILevel8)才开始增加的分类;8.layout:存放项目的布局文件,就是应用程序界面的 XML 文件。9.menu: 菜单文件,同样为 XML 格式,在此可以为应用程序添加菜单。 10.values:该目录中存放的XML文件,定义了各种类型的key-value键值对。一般有 dimens、strings、styles、colors、arrays等。通常程序中用到的尺寸、字符串值、样式、颜色、数组等都在该文件中定义,便于使用和修改。11.AndroidManifest.xml:这是程序的清单文件。应用程序中用到的所有组件,都要在该文件中注册,否则程序无法识别,不能使用。

作业2

  1. Android常见的布局有哪些?
    1、相对父容器布局2、相对控件布局3、线性布局4、表格布局5、网格布局6、帧布局
  1. 写出一个相对父容器布局的代码。(例如,教材配套光盘2-1)
    <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"<Buttonandroid:id="@+id/button1"android:layout_width="200px"android:layout_height="150px"android:layout_alignParentLeft="true"android:layout_alignParentTop="true"android:layout_marginTop="64dp"android:text="@string/button1"/></RelativeLayout>
  1. 写出一个相对控件布局的代码。(例如,教材配套光盘2-2)
    <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"<Buttonandroid:id="@+id/button1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentTop="true"android:layout_centerHorizontal="true"android:layout_marginTop="64dp"android:text="@string/button1"/><Buttonandroid:id="@+id/button2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_above="@+id/button1"android:layout_marginBottom="38dp"android:text="@string/button2"/><Buttonandroid:id="@+id/button3"android:layout_width="200px"android:layout_height="150px"android:layout_below="@+id/button1"android:layout_marginTop="38dp"android:text="@string/button1"/></RelativeLayout>
  1. 写出一个水平线性布局的代码。(例如,教材配套光盘2-3)
    <LinearLayout 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:orientation="horizontal"android:layout_margin="56dp"><Button1android:id="@+id/button1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/button1"/><Button2android:id="@+id/button2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="button2"/></LinearLayout>

作业3

  1. Android常见的基本控件有哪些?
    1、文本类控件2、Button类控件3、时钟控件4、图片控件5、日期与时间控件
  1. 写出使用控件实现具体功能的一般步骤。
1、使用super.setContentView(R.layout.某布局layout文件名)来加载布局文件2、使用super.findViewById(R.id.控件的ID)来获取控件引用3、使用这个引用对控件进行操作,例如添加监听,设置内容等
  1. 写出button注册监听的两种方法。
1.匿名类方式:
public class MainActivity extends Activity {private Button button;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);button=(Button)findViewById(R.id.textView1);/**为Button点击事件注册一个监听器*/
button.setOnClickListener(new OnClickListener(){public void onClick(View v){//添加逻辑}});}
}
2.实现接口类方式:public class MainActivity extends Activity implements OnClickListener{private Button saveBtn;private Button loadBtn;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);saveBtn=(Button)findViewById(R.id.save_data);loadBtn=(Button)findViewById(R.id.load_data);saveBtn.setOnClickListener(this);loadBtn.setOnClickListener(this);}@Overridepublic void onClick(View v) {switch (v.getId()) {                    //获取Button的idcase R.id.load_data://添加逻辑break;default:break;}}
}
  1. 写出一个button注册监听的程序代码。(例如,教材配套光盘3-4)
布局文件,新建两个button:<Buttonandroid:id="@+id/button1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/button1"/><Buttonandroid:id="@+id/button2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alighParentLeft="true"android:layout_marginTop="60dp"android:onClick ="click"android:text="@string/button1"/>逻辑代码public class MainActivity extends Activity {Button button1,button2;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);button1=(Button)findViewById(R.id.button1);button2=(Button)findViewById(R.id.button2);/**为Button点击事件注册一个监听器*/button1.setOnClickListener(new OnClickListener(){public void onClick(View v){//添加逻辑setTitle("Button1注册成功")}});
}public void onClick(View v){//添加逻辑setTitle("Button2注册成功")}}

作业4

  1. Android常见的高级控件有哪些?
1、进度条2、拖动条3、自动完成文本控件4、评分条RatingBar5、下拉列表Spinner6、选项卡TabHost7、图片切换控件ImageSwitcher8、列表视图ListView9、网格视图GridView
  1. 进度条控件提供哪四种样式?
Large、Normal、Small和Horizontal
  1. 评分条有哪三种风格?
RatingBarStyle(默认风格)、RatingBarStyleSmall(小风格)、RatingBarStyleIdicator(大风格)
  1. 写出一个tabhost控件的例子,将导航条移到屏幕下方。(例如,教材配套光盘tabhost项目)
    <?xml version="1.0"ending="utf-8"?><TabHost xmlns:android="http://schemas.android.com/apk/res/android"android:id="@android:id/tabhost"android:layout_width="match_parent"android:layout_height="match_parent"><LinearLayoutandroid:id="@android:id/tab11"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical"></FrameLayoutandroid:id="@android:id/tabcontent"android:layout_width="fill_parent"android:layout_height="fill_parent"android:layout_gravity="bottom"><TabWidgetandroid:id="@android:id/tabs"android:layout_width="fill_parent"android:layout_height="wrap_content"></TabWidget></TextViewandroid:id="@android:id/tv11"android:layout_width="wrap_parent"android:layout_height="wrap_parent"android:Text="TAB1"android:textSize="11pt"/></TextViewandroid:id="@android:id/tv22"android:layout_width="wrap_parent"android:layout_height="wrap_parent"android:Text="TAB2"android:textSize="11pt"/></TextViewandroid:id="@android:id/tv33"android:layout_width="wrap_parent"android:layout_height="wrap_parent"android:Text="TAB3"android:textSize="11pt"/></FrameLayout></LinearLayout></TabHost>逻辑代码:package com.example.tabhost;import android.os.Bundle;import android.widget.TabHost;import android.app.Activity;public class TabHostActivity extends Activity {@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_tab_host);TabHost tabhost = (TabHost)findViewById(android.R.id.tabhost); tabhost.setup(); tabhost.addTab(tabhost.newTabSpec("tab1").setInd

作业5

  1. Android提供的菜单分为哪三类?分别是什么?
选项菜单OptionsMenu 和子菜单Submenu、上下文菜单ContexMenu
  1. Android提供哪些对话框?
    1、普通对话框Dialog2、提示对话框AlertDialog3、进度对话框ProgressDialog4、日期选择对话框DatePickerDialog5、时间选择对话框TimePickerDialog
  1. 写出一个简单的toast项目。(例如,教材配套光盘5-13)
布局代码
<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" ><Buttonandroid:id="@+id/button1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_alignParentTop="true"android:layout_marginLeft="104dp"android:layout_marginTop="111dp"android:text="Button"/></RelativeLayout>逻辑代码:
package com.example.toast;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import android.app.Activity;public class ToastActivity extends Activity {@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_toast);Button button = (Button)findViewById(R.id.button1);button.setOnClickListener(new OnClickListener() {public void onClick(View v) {// TODO Auto-generated method stubToast.makeText(ToastActivity.this, "注册成功", Toast.LENGTH_LONG).show();
}});}  

作业6

  1. Android系统将进程分为哪五类进行管理?
1、Activity生命周期2、单界面程序3、多界面程序4、两个Activity之间传递数据5、Intent和IntentFilter
  1. 简述activity的四种基本状态。
Active(活动):一个新 Activity 启动入栈后,它显示在屏幕最前端,Activity处于活动状态,此时Activity处于栈顶,此时它处于可见并可和用户交互的激活状态。Paused(暂停):当Activity失去焦点时,或被一个新的非全屏的Activity,或被一个透明的Activity放置在栈顶时,Activity就转化为暂停状态。Stopped(停止):当一个Activity被另一个Activity完全覆盖时,被覆盖的Activity就会进入Stopped状态。kill(销毁):当Activity被系统回收掉时,Activity就处于Killed状态。
  1. 画activity的生命周期图
    在这里插入图片描述

http://www.ppmy.cn/news/103986.html

相关文章

测试之路,你知道这些变化吗?突破后助你走得更远...

前言 Python自动化测试&#xff1a;7天练完这60个实战项目&#xff0c;年薪过35w。 目前的面试求职市场上&#xff0c;测试领域有哪些变化&#xff1f; 以这两年软件测试发展经历来看&#xff0c;现在的求职市场&#xff0c;已经不仅仅只考察个人的项目经验和技术能力了&#…

牛客网Linux错题一

1.关于Linux下的进程&#xff0c;论述不正确的是&#xff08;A&#xff09; A.僵尸进程会被init进程接管&#xff0c;僵尸进程不糊造成资源浪费 B.子进程的父进程在它之前退出&#xff0c;子进程会被init进程接管&#xff0c;它不会造成资源浪费 C.进程是资源管理的最小单位…

二十分钟秒懂:实现前后端分离开发(vue+element+spring boot+mybatis+MySQL)

目录 开发者介绍 什么是前后端分离开发 vue与springboot开发的优势 Vue.js 的优势&#xff1a; Spring Boot 的优势&#xff1a; vue与springboot如何实现前后端连接 demo简介 重要部分前端部分代码 重要部分后端代码 后端解决跨域问题 Controller部分 xml部分 se…

vue3的api解读-ref和reactive

目录 构造一个演示框架&#xff08;VUE3&#xff09; /src/examples/Helloworld.tsx /src/mytypes.d.ts /src/main.ts /src/App.tsx /src/layout.css /src/examples/RefExample.tsx /src/examples/ReactiveExample.tsx 思考 Vue提供的Reactive模式和vue.observable有…

机器学习 监督学习 Week2

Lib01 多变量线性回归 依旧是房价预测&#xff0c;但这次引入了多个变量&#xff0c;不仅仅只有房屋面积影响着房价&#xff0c;依旧尝试使用梯度下降算法找到最优的【w,b】&#xff0c;并且习惯使用向量点乘运算提高效率 import copy, math import numpy as np import matplot…

C++入门--初步认识类和对象

0.前言 前面几章&#xff0c;我们一起学习了C和C语言的不同之处&#xff0c;已经算是半只脚迈入了C的“门槛”&#xff0c;本章让我们继续学习C的类和对象。 1.面向对过程和面向对象的初步认识 C语言是面向过程的&#xff0c;关注的是过程&#xff0c;分析出求解问题的步骤&…

一个拦截XSSI 识别Web蜜罐的插件

说明 这是一个带有学习和研究性质的Chrome扩展程序。 功能 截获页面中发起的XSSI请求&#xff0c;通过域名、URI、Query黑名单特征识别阻断可疑的XSSI&#xff08;Jsonp Callback、XSS等&#xff09; 对可疑URL进行深度检测&#xff0c;通过发送请求获取body内容&#xff0c…

windwos 安装 pysqlcipher3

windwos 安装 pysqlcipher3 安装软件 参考别人的文章&#xff0c;有的要安装Tcl Windows(64-bit, x64)&#xff0c;下载地址 但是我没有安装也可以用 安装python 推荐安装 python3.7 日常使用够了&#xff0c;不要追求新出来的版本&#xff0c;不太完善。 安装visual studio…