Android实验设计.docx
- 文档编号:2971672
- 上传时间:2022-11-16
- 格式:DOCX
- 页数:22
- 大小:592.99KB
Android实验设计.docx
《Android实验设计.docx》由会员分享,可在线阅读,更多相关《Android实验设计.docx(22页珍藏版)》请在冰豆网上搜索。
Android实验设计
Android实验设计
实验一:
系统安装与HelloWorld
【目的】
安装智能手机开发相关软件平台。
【要求】
1、完成智能手机开发平台安装、以及相关配置
2、并实现HelloWorld
3、了解项目的基本文件目录结构
【原理】
Eclipse安装原理,Android编程方法
【过程】
1、安装JAVAJDK
下载网址:
2、安装Eclipse
下载网址:
http:
//www.eclipse.org/downloads/
3、安装Android
或
4、安装ADT(AndroidDevelopmentTools)
或
5、安装手机USB驱动
或
如果用模拟器调试,则可暂时不装。
6、建立新项目,实现HelloWorld。
OpenEclipse.
ClickthemenuFile->New->Project.
ExpandtheAndroidfolderandselectAndroidProject.
NametheprojectHelloWorld
得到的文件结构如下:
运行:
选运行的设备,可以是模拟器,也可以是真机(如果已经连接好真实手机的话):
模拟器运行:
真实手机调试:
实验二:
界面设计:
控件与布局
【目的】
Android编程基础,UI设计。
【要求】
1、了解Android编程原理
2、掌握界面控件设计
3、掌握控件的事件处理编程
【原理】
UI设计原理
【过程】
1、了解各种控件的基本功能
各种控件:
Menu
TextView、EditText、
Button
Radiobutton
List
ProgressBar;
2、了解布局Layout的应用
多种Layout:
AbsoluteLayout
FrameLayout
GridView
LinearLayout
ListLayout
RadioGroup
TableLayout
………
3、利用布局安排各种控件,设计良好用户界面
android=" android: orientation="vertical" android: layout_width="fill_parent" android: layout_height="fill_parent" > id="@+id/TextView01" android: layout_width="fill_parent" android: layout_height="wrap_content" android: text="@string/hello" /> id="@+id/EditText01" android: layout_width="fill_parent" android: layout_height="wrap_content" /> id="@+id/ImageView01" android: layout_width="wrap_content" android: layout_height="wrap_content" android: src="@drawable/adr" /> id="@+id/LinearLayout01" android: layout_width="wrap_content" android: layout_height="wrap_content" android: orientation="horizontal"> id="@+id/Button01" android: layout_width="wrap_content" android: layout_height="wrap_content" android: text="@string/btn_name" /> id="@+id/Button02" android: layout_width="wrap_content" android: layout_height="wrap_content" android: text="@string/stp_name" /> id="@+id/progressbar01" android: layout_width="fill_parent" android: layout_height="20px" style="? android: attr/progressBarStyleHorizontal" /> id="@+id/seekbar01" android: layout_width="fill_parent" android: layout_height="20px" style="? android: attr/progressBarStyleHorizontal" /> 实验三: 图形绘制与OpenGL 【目的】 在屏幕绘制各种图形,了解OpenGL 【要求】 1、了解在屏幕绘图方法 2、了解OpenGL 【原理】 【过程】 1、绘制直线、园、曲线等各种图形 2、显示字符 3、利用OpenGL编程方法 publicvoidonDrawFrame(GL10gl){ //一般的opengl程序,首先要做的就是清屏 gl.glClear(GL10.GL_COLOR_BUFFER_BIT|GL10.GL_DEPTH_BUFFER_BIT); //紧接着设置模型视图矩阵 gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity();//清空矩阵 GLU.gluLookAt(gl,0,0,3,0,0,0,0,1,0);//视点变换,将相机位置设置为(0,0,3),同时指向(0,0,0)点 //设置模型位置旋转及缩放信息 gl.glTranslatef(0.0f,0.0f,-1.0f);//将模型位置设置为(0,0,-1) floatangle=30.0f; gl.glRotatef(angle,0,1,0);//绕模型自身Y轴旋转30度 gl.glRotatef(angle,1,0,0);//绕模型自身X轴旋转30度 gl.glScalef(1.2f,1.2f,1.2f);//设置三方向的缩放系数 //设置颜色 gl.glColor4f(0.0f,0.0f,0.0f,1.0f); //渲染立方体 mCube.draw(gl,gl.GL_TRIANGLES); //mCube.draw(gl,gl.GL_LINES); } 实验四: 网络访问与服务 【目的】 掌握Android网络访问方法 【要求】 1、了解手机WEB网站访问编程 2、通过网络进行数据访问 3、了解数据库使用 【原理】 利用Android网络访问协议 【过程】 1、访问WEB网站,通过HttpResponse类,读入网络数据。 HttpClientclient=newDefaultHttpClient(); HttpGetget=newHttpGet(url); HttpResponseresponse=client.execute(get); HttpEntityentity=response.getEntity(); //尝试读取entity的长度,返回-1表示长度未知 longlength=entity.getContentLength(); InputStreamis=entity.getContent(); Strings=null; if(is! =null){ ByteArrayOutputStreambaos=newByteArrayOutputStream(); byte[]buf=newbyte[512]; intch=-1; intcount=0; while((ch=is.read(buf))! =-1){ baos.write(buf,0,ch); count+=ch; //如果长度已知,可以通过taskProgress()通知监听者任务执行的比例 if(length>0){ listener.taskProgress(this,count,length); } //为了更好的演示进度,让线程休眠100ms Thread.sleep(100); } Log.e("HttpTask","length="+baos.toByteArray().length); //返回内容 s=newString(baos.toByteArray()); } returns; 读入网站数据: 实验五: 硬件访问与传感器 【目的】 通过底层API访问手机硬件及手机上的各种传感器 【要求】 1、获取手机上电话、短信等各种功能的编程 2、了解手机上各种传感器的功能与使用方法 【原理】 利用手机本身的功能与相关传感器的使用 【过程】 1、了解程序使用手机电话功能的方法 短信收发: packagecom.android.TinySMS; importandroid.app.Activity; importandroid.app.PendingIntent; importandroid.content.BroadcastReceiver; importandroid.content.Context; importandroid.content.Intent; importandroid.os.Bundle; importandroid.telephony.gsm.SmsManager; i
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Android 实验设计