复习材料《Android移动应用开发技术》_第1页
复习材料《Android移动应用开发技术》_第2页
复习材料《Android移动应用开发技术》_第3页
复习材料《Android移动应用开发技术》_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、1、关于android进程,说法不正确的是( b )a、组件运行所在的进程,是由androidmanifest.xml决定,它可以指定该组件运行于哪个进程。b、背景进程是不为用户所见的activity,但是还会有可能被用户看到,所以它不能被杀死c、当急需内存时,android会决定优先关闭那些空闲的进程d、可视进程一般不会不被系统所杀死2、matrix类的作用( a )a、可以存储缩小或放大比列b、存储文件中的图片信息c、存储资源中的图片信息d、存储内存中的图片信息3、关于主题的说法,错误的是( d )a、它是属性集合b、它可以在程序中来设置c、它通常用于一个activity或所有activi

2、ty上d、它可以用于单个textview上4、setontouchevent 设置返回值为true 和 false有何区别?以下说法较准确是( c )a、没有区别,都能对事件进行监听b、设置为true时 只能在移动时获得一次监听事件,false则可以多次c、设置为false是 ,在处理一次监听事件后,系统将抛弃该次事件d、返回true表示这个消息已经被处理结束,后续的handler不再接收到这个消息二、开发技术设计与应用能力部分注:以下程序均是相关程序或小项目的实现代码,根据每个程序或项目的特性,完成程序空缺部分的内容,使其实现。具体程序代码注释省略。 图1 图2 图3 图41)电话实现 主界

3、面如图1程序描述:完成手机打电话功能。public class mainactivity extends activity protected void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate);setcontentview(r.layout.activity_main);button btn_call = (button)this.findviewbyid(r.id.btn_call);btn_call.setonclicklistener(new btncall();private clas

4、s btncall implements onclicklistener (1)public void onclick(view v) / todo auto-generated method stubedittext et_number = (edittext) mainactivity.this.findviewbyid(r.id.et_number);string s_number = et_number.gettext().tostring().trim();(2)intent i_call = new intent();i_call.setaction(intent.action_c

5、all(3));i_call.setdata(uri.parse(tel:+s_number);startactivity(i_call); (4)2)动画实现 主界面如图2程序描述:手机屏幕触摸后演示动画,假设xml文件已经设置好,id资源为:r.drawable.pandapublic class mainactivity extends activity imageview iv_action;animationdrawable ad_action;protected void oncreate(bundle savedinstancestate) super.oncreate(save

6、dinstancestate);setcontentview(r.layout.activity_main);iv_action = (imageview)this.findviewbyid(r.id.iv_action);iv_action.setbackgroundresource(5)(r.drawable.panda);ad_action = (animationdrawable) iv_action.getbackground();public boolean ontouchevent(motionevent event) ad_action.start();(6)return su

7、per.ontouchevent(event);3)撕衣服游戏实现项目描述:划动屏幕时完成撕衣服效果,并产生撕衣服声音(sound.mp3)public class mainactivity extends activity imageview iv_upper;imageview iv_below;bitmap bmp_upper;bitmap bmp_below;bitmap bmp_upper_alter;canvas canvas;paint paint;soundpool sp;overrideprotected void oncreate(bundle savedinstances

8、tate) super.oncreate(savedinstancestate);setcontentview(r.layout.activity_main);sp = new soundpool(5, audiomanager.stream_system(7), 5);sp.load(getapplicationcontext(), r.raw.sound, 0);options opts = new options();opts.insamplesize = 2;iv_upper = (imageview) this.findviewbyid(r.id.iv_upper);iv_below

9、 = (imageview) this.findviewbyid(r.id.iv_below);bmp_upper = bitmapfactory.decoderesource(getresources(), r.drawable.upper, opts);bmp_below = bitmapfactory.decoderesource(getresources(), r.drawable.below, opts);bmp_upper_alter = bitmap.createbitmap(bmp_upper.getwidth(), bmp_upper.getheight(), bmp_upp

10、er.getconfig()(8));iv_upper.setimagebitmap(bmp_upper_alter(9));iv_below.setimagebitmap(bmp_below(10));paint = new paint();paint.setcolor(color.black(11));paint.setstrokewidth(5);canvas = new canvas(bmp_upper_alter(12));canvas.drawbitmap(bmp_upper(13), new matrix(), paint);iv_upper.setontouchlistener

11、(new ontouchlistener() public boolean ontouch(view v, motionevent event) / todo auto-generated method stubint x;int y;switch (event.getaction()(14)) case motionevent.action_move:x = (int)event.getx();y = (int)event.gety();sp.play(1, 1, 1, 0, 0, 1);for(int i=-20; i21;i+)for(int j=-20; j21; j+)bmp_upp

12、er_alter.setpixel(i+x, j+y, color.transparent(15));iv_upper.setimagebitmap(bmp_upper_alter(16));break;default:break;return true;);4)数据库技术项目项目描述:完成数据库的增、删、改、查设计,完成数据库数据的显示界面设计及实现。注:相关文件及包结构关系如下,完成相关设计及实现package com.android.dao.dao;import 省略;public class databaseopenhelper extends sqliteopenhelper pub

13、lic databaseopenhelper(context context) super(context, testdb.db, null, 1); /完成数据库名称等设置overridepublic void oncreate(sqlitedatabase db) / todo auto-generated method stubdb.execsql(create table person (id integer primary key autoincrement(17), name varchar(20), telnum varchar(20); /数据表结构设计其余省略package

14、com.android.dao.dao;import 省略public class dbdao databaseopenhelper helper;public dbdao()public dbdao(context context)helper = new databaseopenhelper(context)(18);public void insert(string name, string telnum)/数据表成员增加sqlitedatabase db = helper.getwritabledatabase()(19);db.execsql(insert into person (

15、name, telnum) values (?,?), new objectname, telnum);db.close();public void delete(string name)/数据表成员删除sqlitedatabase db = helper.getwritabledatabase();db.execsql(delete from person where name = ?, new objectname);db.close();public void update(string name, string newnumber)/数据表成员更新sqlitedatabase db =

16、 helper.getwritabledatabase();db.execsql(update person set telnum = ? where name = ?, new objectnewnumber(20), name(21));db.close();public boolean find(string name) /数据表成员条件查找boolean result = false;cursor cs;sqlitedatabase db = helper.getwritabledatabase();cs = db.rawquery(select * from person where

17、 name = ?, new stringname);result = cs.movetonext();cs.close();(22)db.close();return result;public list findall()/数据表成员查找全部cursor cs;list person = new arraylist();sqlitedatabase db = helper.getreadabledatabase();(23)cs = db.rawquery(select * from person, null);while(cs.movetonext()int id = cs.getint

18、(cs.getcolumnindex(id);string name = cs.getstring(cs.getcolumnindex(name);string telnum = cs.getstring(cs.getcolumnindex(telnum);person p = new person(id, name, telnum);person.add(p); (24)cs.close();db.close();return person;(25)package com.android.dao.dao;public class person int id;string name;strin

19、g telnum;public person(int id, string name, string telnum)this.id = id; = name;this.telnum = telnum;其余省略package com.android.dao;import省略public class mainactivity extends activity linearlayout layout_root;overrideprotected void oncreate(bundle savedinstancestate) super.oncreate(savedinstancestate);setcontentview(r.layout.activity_ma

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论