智能移动终端软件开发实验报告_第1页
智能移动终端软件开发实验报告_第2页
智能移动终端软件开发实验报告_第3页
智能移动终端软件开发实验报告_第4页
智能移动终端软件开发实验报告_第5页
已阅读5页,还剩25页未读 继续免费阅读

下载本文档

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

文档简介

1、实验题目实验一:描述用户界面实验地点502实验日期3-24机器号27一、实验目的学会写自己的第一个Android程序,从最简单的从模拟器上输出“Hello,world!”开始。二、实验内容1,先自己创建一个项目。2.此时在窗口右边有一个“Activities”的项目,右击部署到模拟器上三、实验步骤及结果1, helloActivity.JAVApackage net.lightwinner.app;import android.app.Activity;import android.os.Bundle;package net.lightwinner.app;import android.app

2、.Activity;import android.os.Bundle;package net.lightwinner.app;package net.lightwinner.app;import android.app.Activity;package net.lightwinner.app;import android.app.Activity;import android.os.Bundle;public class helloActivity extends Activity /* Called when the activity is first created. */ Overrid

3、e public void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); setContentView(R.layout.main); 2.MAIN.JAVA<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="" android:orientation="vertical" android:layout_width=&q

4、uot;fill_parent" android:layout_height="fill_parent"><TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="string/hello" /></LinearLayout> 3.STRING <?xml version="1.0" encoding="ut

5、f-8"?><resources> <string name="hello">Hello World, helloActivity!</string> <string name="app_name">我的第一个应用</string></resources>四、小结(问题及收获)让屏幕上显示“Hello,world!”,窗口右边有一个“Activities”的项目,打开项目,里面有“res”选项,打开后有“layout>main.xml”,打开如下: ,屏幕上输出

6、的“Hello world, main ”可能出自这里,试着把中的“string/hello”改为“Hello,world!”则屏幕上输出了。实验科目智能移动终端软件开发实验题目实验二:BMI应用程序设计实验地点5-502实验日期4-12机器号27一、 实验目的初步掌握Android布局开发并运用多个TextView界面组件。二、 实验内容设计一个允许我们输入身高,体重并计算bmi值的程序,在屏幕上显示bmi的同时,并弹出“你应该节食或多吃”的信息。只要bmi超过25就算偏胖,低于20就算偏瘦。三、实验步骤及结果1代码(1)main<?xml version="1.0"

7、; encoding="utf-8"?><LinearLayout xmlns:android="" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" ><TextView android:layout_width="fill_parent" android:layout_height="w

8、rap_content" android:text="身高(cm)" /> <EditText android:id="+id/height" android:layout_width="fill_parent" android:layout_height="wrap_content" android:numeric="integer" android:text="" /> <TextView android:layout_width=&qu

9、ot;fill_parent" android:layout_height="wrap_content" android:text="体重(kg)"/> <EditText android:id="+id/weight" android:layout_width="fill_parent" android:layout_height="wrap_content" android:numeric="integer" android:text="&

10、quot;/> <Button android:id="+id/submit" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="计算BMI值" /> <TextView android:id="+id/result" android:layout_width="fill_parent" android:layout_height=

11、"wrap_content" android:text=""/> <TextView android:id="+id/suggest" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" /></LinearLayout>(2)Activity.JAVApackage com.demo.android.bmi;import

12、java.text.DecimalFormat;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.EditText;import android.widget.TextView;public class Bmi extends Activity /* Called when the activity is f

13、irst created. */ Override public void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button=(Button)findViewById(R.id.submit); button.setOnClickListener(calcBMI); private OnClickListener calcBMI=new OnClickListener () public void onClick

14、(View v) DecimalFormat nf=new DecimalFormat("0.00"); EditText fieldheight=(EditText)findViewById(R.id.height); EditText fieldweight=(EditText)findViewById(R.id.weight); double height=Double.parseDouble(fieldheight.getText().toString()/100; double weight=Double.parseDouble(fieldweight.getTe

15、xt().toString(); double BMI=weight/(height*height); TextView result=(TextView)findViewById(R.id.result); result.setText("Your BMI is "+nf.format(BMI); TextView fieldsuggest=(TextView)findViewById(R.id.suggest); if(BMI>25) fieldsuggest.setText(R.string.advice_heavy); else if(BMI<20) f

16、ieldsuggest.setText(R.string.advice_light); else fieldsuggest.setText(R.string.advice_average) ;(3)STRING <?xml version="1.0" encoding="utf-8"?><resources> <string name="app_name">BMI</string> <string name ="height">身高(CM)</str

17、ing> <string name ="weight">体重(KG)</string> <string name ="bmi_btn">计算BMI值</string> <string name ="bmi_result">你的BMI值是</string></resources>四、小结(问题及收获)通过实验可以了解一下整个程序制作的过程和程序制作的思路,打消掉了原先对在一门新的课程上的了解的误区和信心的不足。实验科目智能移动终端软件开发实验题目实

18、验三:添加列表活动(ListActivity)实验地点5-502实验日期4-24机器号27一、 实验目的 添加列表活动(ListActivity)。 二、实验内容1.用户在列表查看画面(原来的Activity)上点选项目; 2.应用程序取得点击项目的row ID;3.应用程序用一个Internet携带row ID数据,前往新Activity(编辑画面);4.应用程序在新Activity中,取得传入的row ID数据;5.应用程序在新Activity中,通过数据库接口来查询符合row ID的单笔条目;6.应用程序在新Activity中,将查询到的条目显示在文本编辑字段中;7.编辑完成后,按下ok

19、ay按钮将修改保存到数据库,并回到列表查看画面。三、实验步骤及结果1,MainActivitypackage net.lightwinner.note;import android.app.Activity;import android.os.Bundle;public class MainActivity extends Activity /* Called when the activity is first created. */ Override public void onCreate(Bundle savedInstanceState) super.onCreate(savedIn

20、stanceState); setContentView(R.layout.main); 2MAIN<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <L

21、istView android:id="+id/android:list" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="+id/empty" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravit

22、y="center_vertical" android:text="暂时没有数据显示"/></LinearLayout>3String<?xml version="1.0" encoding="utf-8"?><resources> <string name="hello">Hello World, MainActivity!</string> <string name="app_name">记事本

23、程序</string></resources>四、小结(问题及收获)“电话本”的实现,可以添加,方法源码有调用可以实现这个功能。实验科目智能移动终端软件开发实验题目实验四:音频播放器实验地点5-502实验日期5-12机器号27一、实验目的 用智能移动终端软件开发实现音频播放器。二、实验内容设计一个音频播放器。三、实验步骤及结果1.string.xml<?xml version="1.0" encoding="utf-8"?><resources> <string name="hello&qu

24、ot;>Hello World, MainActivity!</string> <string name="app_name">音频播放器</string> <string name="">音频文件的名称</string> <string name="play">播放</string> <string name="pause">暂停</string> <string name="rese

25、t">重播</string> <string name="stop">停止</string> <string name="continues">继续</string></resources>2. MainActivitypackage net.lightwinner.audio;import java.io.File;import java.io.IOException;import android.app.Activity;import android.media.

26、MediaPlayer;import android.os.Bundle;import android.os.Environment;import android.util.Log;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.EditText;public class MainActivity extends Activity private static final String TAG = "

27、MainActivity"private Button btnPlay;private Button btnPause;private Button btnReset;private Button btnStop;private EditText ;private MediaPlayer mediaPlayer;private int position; /* Called when the activity is first created. */ Override public void onCreate(Bundle savedInstanceState) super.onCr

28、eate(savedInstanceState); setContentView(R.layout.main); = (EditText)this.findViewById(R.id.); btnPlay = (Button)this.findViewById(R.id.play); btnPause = (Button)this.findViewById(R.id.pause); btnReset = (Button)this.findViewById(R.id.reset); btnStop = (Button)this.findViewById(R.id.stop); mediaPlay

29、er = new MediaPlayer(); BtnOnClickListener listener = new BtnOnClickListener(); btnPlay.setOnClickListener(listener); btnPause.setOnClickListener(listener); btnReset.setOnClickListener(listener); btnStop.setOnClickListener(listener); private final class BtnOnClickListener implements OnClickListenerO

30、verridepublic void onClick(View v) / TODO Auto-generated method stubButton btn = (Button)v;try switch(v.getId()case R.id.play:play();break;case R.id.pause:if(mediaPlayer.isPlaying()mediaPlayer.stop();position = mediaPlayer.getCurrentPosition();btn.setText(R.string.continues);elseplay();mediaPlayer.s

31、eekTo(position);btn.setText(R.string.pause);position=0;break;case R.id.reset:play();mediaPlayer.seekTo(0);break;case R.id.stop:if(mediaPlayer.isPlaying()mediaPlayer.stop();break; catch (Exception e) / TODO Auto-generated catch block/e.printStackTrace();Log.e(TAG, e.toString(); private void play() th

32、rows IOException String = ().toString(); = new (),);mediaPlayer.reset();mediaPlayer.setDataSource();mediaPlayer.prepare();/缓冲数据mediaPlayer.start();3.main<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="" android:orientation="vertical"

33、; android:layout_width="fill_parent" android:layout_height="fill_parent" ><TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="string/" /> <EditText android:layout_width="fill_parent" a

34、ndroid:layout_height="wrap_content" android:id="+id/" android:text="sens kaishin.mp3" /> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:lay

35、out_width="wrap_content" android:layout_height="wrap_content" android:id="+id/play" android:text="string/play"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="+id/pause" android

36、:text="string/pause"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="+id/reset" android:text="string/reset"/> <Button android:layout_width="wrap_content" android:layout_height="

37、;wrap_content" android:id="+id/stop" android:text="string/stop"/> </LinearLayout></LinearLayout>三、 小结(问题及收获)曲目名称的显示,文件的加载,文件的读取,各个功能按钮的实现。实验科目智能移动终端软件开发实验题目实验五:添加新活动(Activity)实验地点实验楼409实验日期2012-5-24机器号27一、 实验目的1.添加xml文件。2.程序中创建新的Activity类文件。3.原Activity类中添加star

38、tActivity函数。二、实验内容 添加新活动(Activity)。三、实验步骤及结果.代码 (1)main.xml代码 <?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"

39、><TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="主界面" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="打开" android:id="+id/butt

40、on" /> </LinearLayout>(2)other.xml代码<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="fill_

41、parent" android:layout_height="wrap_content" android:text="这是测试界面" /></LinearLayout>(3)BMIActivity代码package net.lightwinner.activity;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.view.View.

42、OnClickListener;import android.widget.Button;public class BMIActivity extends Activity /* Called when the activity is first created. */ Override public void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button= (Button)this.findViewById

43、(R.id.button); button.setOnClickListener(new OnClickListener() Override public void onClick(View v) Intent intent= new Intent(BMIActivity.this,OtherActivity.class); startActivity(intent); ); OtherActivity代码package net.lightwinner.activity;import android.app.Activity;import android.os.Bundle;public c

44、lass OtherActivity extends Activity Overrideprotected void onCreate(Bundle savedInstanceState) / TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.other);四、小结(问题及收获)Java的记事本实现的机器不同,其中的功能基本一致,添加删除等等一些文本的输入设置,text的文字区域也有显示功能,最后还得保存。实验科目智能移动终端软件开发实验题目实验六:传送数据到新意图

45、实验地点502实验日期5-27机器号27一、实验目的传送数据到新意图。二、实验内容信息的显示,信息的归总,信息的浏览,和信息的使用。不同软件之间信息的安全传递三、实验步骤及结果1.BMIActivitypackage net.lightwinner.activity;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.wi

46、dget.Button;import android.widget.EditText;public class BMIActivity extends Activity /* Called when the activity is first created. */ Override public void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button=(Button)this.findViewById(Rm

47、it); final EditText height_field=(EditText)this.findViewById(R.id.height); final EditText weight_field=(EditText)this.findViewById(R.id.weight); button.setOnClickListener(new OnClickListener() public void onClick(View v) / TODO Auto-generated method stubIntent intent=new Intent(BMIActivity.this,Repo

48、rtActivity.class);Bundle bundle=new Bundle();String height=height_field.getText().toString();String weight=weight_field.getText().toString();bundle.putString("KEY_HEIGHT",height);bundle.putString("KEY_WEIGHT",weight);intent.putExtras(bundle);startActivity(intent); ); 2.main<?x

49、ml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" ><TextView android:layout_width="fill_parent" andr

50、oid:layout_height="wrap_content" android:text="身高(cm)" /> <EditText android:id="+id/height" android:layout_width="fill_parent" android:layout_height="wrap_content" android:numeric="integer" android:text="" /> <TextView

51、 android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="体重(kg)" /> <EditText android:id="+id/weight" android:layout_width="fill_parent" android:layout_height="wrap_content" android:numeric="integer&

52、quot; android:text="” <Button android:id ="+id/commit"android:layout_width="fill_parent" android:layout_height="wrap_content" android:drawableBottom ="#bbbf" android:text="提交"/> /> <TextView android:id="+id/result" android:

53、layout_width="fill_parent" android:layout_height="wrap_content" android:text="" /> <TextView android:id="+id/suggest" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="" /> </LinearL

54、ayout>3.string<?xml version="1.0" encoding="utf-8"?><resources> <string name="hello">Hello World, BMIActivity!</string> <string name="app_name">Activity之间的通信</string> <string name="advice_heavy">你该节食了</

55、string> <string name="advice_light">你该多吃点</string> <string name="advice_average">体型很棒哦</string> <string name="return_lable">返回</string></resources>四、小结(问题及收获)信息的显示,信息的归总,信息的浏览,和信息的使用。不同软件之间信息的安全传递实验科目智能移动终端软件开发实验题目实验七:活动的生命周期

56、ActivityLifeCycle实验地点502实验日期6-20机器号27一、实验目的活动的生命周期ActivityLifeCycle。二、实验内容活动的监视来自于技术和平台的支持。三、实验步骤及结果程序:ActivityLifeCyclemainfest.xml<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="" package="net.lightwinner.lifecycle" android:versionCod

57、e="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" /> <application android:icon="drawable/icon" android:label="string/app_name"> <activity android:name=".MainActivity" android:label="string/app_name&

58、quot;> <intent-filter> <action android:name="ent.action.MAIN" /> <category android:name="ent.category.LAUNCHER" /> </intent-filter> </activity><activity android:name=".SecondActivity" android:theme="android:style/Theme.Dialog"/><activity android:name=".ThirdActivity

温馨提示

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

评论

0/150

提交评论