Android实验报告模板-实验三_第1页
Android实验报告模板-实验三_第2页
Android实验报告模板-实验三_第3页
Android实验报告模板-实验三_第4页
Android实验报告模板-实验三_第5页
已阅读5页,还剩15页未读 继续免费阅读

付费下载

下载本文档

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

文档简介

电子信息学院实验报告书课程名:《操作系统原理》题目:实验三Android的控制层开发实验类别:【验证、设计】班级:学号:姓名:评语:评语:学习态度□积极□一般□较差原理阐述□清晰□基本清晰□不清晰实验结果□正确□基本正确□部分正确思考题探究□深入□较深入□未做答书写规范性□规范□基本符合要求□未符合要就成绩:指导教师:林晓晨批阅时间:年月日《操作系统原理》实验报告 -PAGE19-实验题目Android的控制层开发2、实验目的与要求(1)实验目的:本次实验的目的是让同学熟悉Intent和Activity的使用。了解利用Intent实现进程间的通信,学会利用Intent进行Activity的跳转,以及链接网页信息。(2)实验要求:1.熟悉Intent与Activity的使用;2.掌握Activity启动另一个Activity的方法;3.会使用Intent对象进行Activity间意图的传达。3、实验步骤与源程序(1)新建First.java和Second.java(2)整个工程的结构为:(3)java代码(3.1)MainActivity.javapackagelin.example.hellointent;importandroid.app.Activity;importandroid.content.Intent;import.Uri;importandroid.os.Bundle;importandroid.view.View;importandroid.widget.Button;publicclassMainActivityextendsActivity{ @Override publicvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Buttonbtn1=(Button)findViewById(R.id.btn1); btn1.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ Intentintent=newIntent(); Stringdata=""; Uriuri=Uri.parse(data); intent.setAction(intent.ACTION_VIEW); intent.setData(uri); startActivity(intent); } }); Buttonbtn2=(Button)findViewById(R.id.btn2); btn2.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ Intentintent=newIntent(); Stringdata="tel:123456"; Uriuri=Uri.parse(data); intent.setAction(intent.ACTION_DIAL); intent.setData(uri); startActivity(intent); } }); Buttonbtn3=(Button)findViewById(R.id.btn3); btn3.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ Intentintent=newIntent(); intent.setClass(MainActivity.this,First.class); startActivity(intent); } }); Buttonbtn4=(Button)findViewById(R.id.btn4); btn4.setOnClickListener(newView.OnClickListener(){ @Override publicvoidonClick(Viewv){ Intentintent=newIntent(); intent.setClass(MainActivity.this,Second.class); startActivity(intent); } }); } }(3.2)First.javapackagelin.example.hellointent;importandroid.app.Activity;importandroid.os.Bundle;publicclassFirstextendsActivity{ @Override protectedvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_first); }}(3.3)Second.javapackagelin.example.hellointent;importandroid.app.Activity;importandroid.os.Bundle;publicclassSecondextendsActivity{ @Override protectedvoidonCreate(BundlesavedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.activity_second); }}(4)layout代码(4.1)activity_main.xml<LinearLayoutxmlns:android="/apk/res/android"xmlns:tools="/tools"android:id="@+id/container"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical"tools:context="lin.example.hellointent.MainActivity"tools:ignore="MergeRootFrame"><Buttonandroid:id="@+id/btn1"android:layout_width="fill_parent"android:layout_height="wrap_content"android:text="查看网站"/><Buttonandroid:id="@+id/btn2"android:layout_width="fill_parent"android:layout_height="wrap_content"android:text="拨打电话:123456"/><Buttonandroid:id="@+id/btn3"android:layout_width="fill_parent"android:layout_height="wrap_content"android:text="Intent按钮"/><Buttonandroid:id="@+id/btn4"android:layout_width="fill_parent"android:layout_height="wrap_content"android:text="发短信"/></LinearLayout>(4.2)activity_first.xml<FrameLayoutxmlns:android="/apk/res/android"xmlns:tools="/tools"android:id="@+id/container"android:layout_width="fill_parent"android:layout_height="fill_parent"tools:context="lin.example.hellointent.First"tools:ignore="MergeRootFrame"><TextViewandroid:id="@+id/textView1"android:layout_width="fill_parent"android:layout_height="match_parent"android:text="上海电机学院"/></FrameLayout>(4.3)activity_second.xml<LinearLayoutxmlns:android="/apk/res/android"xmlns:tools="/tools"android:id="@+id/container"android:layout_width="fill_parent"android:layout_height="fill_parent"tools:context="lin.example.hellointent.Second"tools:ignore="MergeRootFrame"><TextViewandroid:id="@+id/textView1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="内容"/><EditTextandroid:id="@+id/editText1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_weight="1"android:hint="请输入短信内容..."android:textColorHint="#238745"><requestFocus/></EditText></LinearLayout>5运行Console:Android[2014-05-1016:55:03-HelloIntent][2014-05-1016:55:03-HelloIntent]AndroidLaunch![2014-05-1016:55:03-HelloIntent]adbisrunningnormally.[2014-05-1016:55:03-HelloIntent]Performinglin.example.hellointent.MainActivityactivitylaunch[2014-05-1016:55:04-HelloIntent]AutomaticTargetMode:launchingnewemulatorwithcompatibleAVD'AVD_for_3_7_WVGA_Nexus_One'[2014-05-1016:55:04-HelloIntent]Launchinga

温馨提示

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

评论

0/150

提交评论