Android应用程序开发期末大作业(1)
一、简答题 (每小题5分,4小题,共20分)
1、(1) android大众常用的五种布局(5分)
答:FrameLayout(框架布局),LinearLayout (线性布局),AbsoluteLayout(绝对布局),RelativeLayout(相对布局),TableLayout(表格布局)。
(2)两个Activity之间怎么传递数据?(5分)
答:基本数据类型可以通过. Intent 传递数据,extras.putDouble(key, value),intent.putExtras(extras)。
2、(1)请描述一下Intent 和Intent Filter(5分)
答:Intent和IntentFilter是Android和一种消息通信机制,可以让系统的组件之间进行通信。信息的载体就是Intent,它可以是一个要完成的动作请求,也可以一般性的消息广播,它可以由任意一个组件发出。消息,也就是Intent,最终也是要被组件来进行处理和消化。
(2)谈谈UI中, Padding和Margin有什么区别?(5分)
答:Padding 为内边框,指该控件内部内容,如文本/图片距离该控件的边距;Margin 为外边框,指该控件距离边父控件的边距
二、操作题(每题20分,共4题,共80分)
(1)用TextView和button及其属性实现在界面显示“Hello The Android World!”。
新建android项目如AI01,在项目的/AI01/src/com/example/ai01/MainActivity.java文件写下如下代码,注意包名!
package com.example.ai01;import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.TextView;public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);super.onCreate(savedInstanceState); TextView textView = (TextView)findViewById(R.id.textView01); Button button = (Button)findViewById(R.id.button01);}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;}@Overridepublic boolean onOptionsItemSelected(MenuItem item) {// Handle action bar item clicks here. The action bar will// automatically handle clicks on the Home/Up button, so long// as you specify a parent activity in AndroidManifest.xml.int id = item.getItemId();if (id == R.id.action_settings) {return true;}return super.onOptionsItemSelected(item);}
}
在项目的/AI01/res/layout/activity_main.xml文件写下如下代码。
<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:paddingBottom="@dimen/activity_vertical_margin"android:paddingLeft="@dimen/activity_horizontal_margin"android:paddingRight="@dimen/activity_horizontal_margin"android:paddingTop="@dimen/activity_vertical_margin"tools:context="com.example.ai01.MainActivity" ><TextView android:id="@+id/textView01" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/hello"/><Buttonandroid:id="@+id/button01"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@+id/textView01"android:text="@string/button" /></RelativeLayout>
在项目的 /AI01/res/values/strings.xml 文件写下如下代码。
<?xml version="1.0" encoding="utf-8"?>
<resources><string name="app_name">AI01</string><string name="hello_world">Hello world!</string><string name="action_settings">Settings</string><string name="hello">Hello The Android World!</string> <string name="button">I am a button!</string>
</resources>
运行效果如下。
(2)利用Intent及其方法和Activity实现如图调用拨号程序。
新建android项目如AI02,在项目的/AI02/src/com/example/ai02/MainActivity.java文件写下如下代码,注意包名!
package com.example.ai02;import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;public class MainActivity extends Activity {private TextView tvTelphone=null; private Button btnCall=null;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tvTelphone=(TextView)super.findViewById(R.id.telphone); btnCall=(Button)super.findViewById(R.id.call); btnCall.setOnClickListener(new OnClickListener(){ public void onClick(View v) { String Telphone=tvTelphone.getText().toString(); Uri uri=Uri.parse("tel:"+Telphone); Intent intent=new Intent(); intent.setAction(Intent.ACTION_CALL); intent.setData(uri); MainActivity.this.startActivity(intent); } });}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;}@Overridepublic boolean onOptionsItemSelected(MenuItem item) {// Handle action bar item clicks here. The action bar will// automatically handle clicks on the Home/Up button, so long// as you specify a parent activity in AndroidManifest.xml.int id = item.getItemId();if (id == R.id.action_settings) {return true;}return super.onOptionsItemSelected(item);}
}
在项目的/AI02/res/layout/activity_main.xml文件写下如下代码。
<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:paddingBottom="@dimen/activity_vertical_margin"android:paddingLeft="@dimen/activity_horizontal_margin"android:paddingRight="@dimen/activity_horizontal_margin"android:paddingTop="@dimen/activity_vertical_margin"tools:context="com.example.ai02.MainActivity" ><TextView android:id="@+id/tel" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="请输入电话号码:" /> <EditText android:id="@+id/telphone" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/tel"android:ems="10" ><requestFocus /> </EditText><Buttonandroid:id="@+id/call"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@+id/telphone"android:text="呼叫" /></RelativeLayout>
在项目的 /AI02/AndroidManifest.xml 文件添加如下代码。
<uses-permission android:name="android.permission.CALL_PHONE"/>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.example.ai02"android:versionCode="1"android:versionName="1.0" ><uses-sdkandroid:minSdkVersion="17"android:targetSdkVersion="17" /><uses-permission android:name="android.permission.CALL_PHONE"/><applicationandroid:allowBackup="true"android:icon="@drawable/ic_launcher"android:label="@string/app_name"android:theme="@style/AppTheme" ><activityandroid:name=".MainActivity"android:label="@string/app_name" ><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity></application></manifest>
运行效果如下。
Android应用程序开发期末大作业(1)相关推荐
- Android期末大作业、移动应用开发期末大作业(教练预约APP)
移动应用开发期末大作业(教练预约APP) 运动健身APP 用户:小型健身房和健身者 功能:注册登录,预约教练,发布讨论,删除讨论 页面展示: 欢迎页面:(三秒自动跳转到主页面) 首页: 我的: 登录注 ...
- Android app开发期末大作业“快乐七巧板”开发总结
写在前面 大二的暑假过去一半了,我终于想起来把期末大作业写出来了.本文的主要目的就是总结一学期安卓开发入门和最后期末大作业相关的一些收获和感受. 给自己一个总结和给以后再去学习的相关内容的小伙伴们一咪 ...
- Web程序设计基础期末大作业——模仿QQ飞车手游S联赛官网编写的网页
QQ飞车手游是我非常喜欢的游戏,也是我现在为数不多的常在玩的游戏,刚好我Web程序设计基础的大作业是要做一套网站,我就借此机会模仿飞车S联赛官网的页面自己做了一个网页,又加了一些自己的元素,由于我做这 ...
- php网站开发期末大作业,网页设计期末大作业报告..doc
网页设计期末大作业报告. 南开大学滨海学院 本 科 生 论 文(设 计) 中文题目:外文题目:Website design and implementation based on Web develo ...
- 【安卓开发】简单记账app功能实现开发-期末大作业个人总结
说在前面: 由于这一次的大作业涉及到的代码部分过于长,所以博客里不放相关代码: 工程&apk&记账app原型&素材资源链接:https://download.csdn.net/ ...
- php网站开发期末大作业,大学生期末网页大作业
[实例简介] 6页面的网页设计,是个人主页类型.包含了6个页面,包含视频.脚本等元素.水平不高,但交选修作业就足够了. [实例截图] [核心代码] 为ai而狂 └── 为ai而狂 ├── FLVPla ...
- 【项目】游戏开发期末大作业 之 基于Java的小游戏 “大鱼吃小鱼“ (代码素材齐全)
1.EatFish游戏开发过程 1.游戏窗口创建 2.添加背景图片 3.启动封面 4.启动页面的点击事件 5.游戏开始的背景添加 6.双缓存解决闪屏问题 7.敌方鱼类的生成 8.我方鱼的生成 9.我方 ...
- web前端开发——期末大作业网页制作——web网页设计期末课程大作业 HTML+CSS+JS网页设计期末课程大作业 web前端开发技术 web课程设计 网页规划与设计
HTML实例网页代码, 本实例适合于初学HTML的同学.该实例里面有设置了css的样式设置,有div的样式格局,这个实例比较全面,有助于同学的学习,本文将介绍如何通过从头开始设计个人网站并将其转换为代 ...
- 安卓期末大作业——Android水果连连看
详情介绍 功能描述: 该连连看实现了基本的游戏功能,还实现了重开.提醒.背景音乐等功能,适合新手学习.搭建方法请看教菜单中的androidstudio项目搭建教程. 开发语言: java 技术框架: ...
最新文章
- linux中用gtk编写的聊天室能运行的,CHAT_ROOM
- 用MsgWaitForMultipleObjects代替WaitForSingleObject和WaitForMultipleObjects()
- 减少重复工作,通过 Annotation Processor 自动完成源码的生成
- SYBASE性能优化
- [历朝通俗演义-蔡东藩-前汉]第008回 葬始皇骊山成巨冢 戮宗室豻狱构奇冤
- Eureka(易瑞卡)注册中心【Zookeeper】分布式设计定理CAP
- 【转】JMeter Tutorial的安装和具体操作
- @PostConstruct @DependsOn
- 2016全国大学生信息安全竞赛(Misc)
- Vue前端实战——外卖商家
- netty系列之:请netty再爱UDT一次
- NB-IOT的基础知识
- PWM波控制舵机总结
- 关于短视频平台框架搭建与技术选型探讨
- How To Download Youtube Videos Without any software
- 机器学习入坑指南(十):猫狗大战之数据集准备
- JAVA抽象类向上转型练习——编程例题之计算各种图形面积之和
- CSS 经典布局(两栏布局 + 三栏布局 + 圣杯布局 + 双飞翼布局)
- Java码农怎样才能成为年薪60W的高级架构师进入BAT?
- ultral edit使用方法大全
热门文章
- 华为为何“厚”此“薄”彼?——观华为2016年企业形象广告
- 明明的随机数,程序的理解
- 弘玑创始人兼CEO高煜光获得2022上海城市数字化转型“领军先锋”决赛一等奖
- cityengine快速创建城市模型
- SAP进口关税及增值税处理
- HTML5七夕情人节表白网页(新年倒计时+白色雪花飘落) HTML+CSS+JS 求婚 html生日快乐祝福代码网页 520情人节告白代码 程序员表白源码 抖音3D旋转相册 js烟花代码 c
- {}企业如何利用邮件进行推广?
- Android使用SwipeRefreshLayout实现下拉刷新
- 谷歌地图导入谷歌地球:制作轨迹与游览
- 4款黑科技级别的宝藏APP,轻松满足你的多种需求,请低调收藏