




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
+/温州大学物理与电子信息工程学院Android应用开发 实验报告实验名称:实验1-UI基本部件编程班级:14网工姓名:周东方学号验地点:5b308日期:一、实验目的:1、 熟悉XML布局文件与UI基本部件的关系2、 掌握UI基本部件的Java编程技术二、 实验环境:1、 PC机+Windows操作系统+JAVASDK1.6以上2、 Eclipse+AndroidSDK+AVD或AndroidStudio三、 实验内容和要求:进阶一1、 熟悉编程环境2、 学习理解Button验证程序3、 学习理解CheckBox验证程序4、 学习理解EditText验证程序5、 学习理解RadioButton验证程序进阶二1、编写一个程序,在一个垂直布局LinearLayout里有4个水平布局的LinearLayout和2个TextView。第一个水平布局的LinearLayout里面有1个TextView部件和EditText部件;第二个水平布局的LinearLayout里面依次放有1个Button和1个TextView部件,Button点击后能把第一个水平布局里的EditText的内容更新到Button右边的TextView部件上;第三个水平布局的LinearLayout里有一组RadioButton(三个);第四个水平布局的LinearLayout里有三个Checkbox;最后2个TextView,能分别显示RadioButton和CheckBox的选中状态。(要求:包的名和Activity的名称需包含你的姓名拼音信息)注意事项:1)程序的包名或java文件要体现与你姓名相关的信息;2)在实验结果中贴截图应体现你所实现的所有功能。*进阶三1、 第一个水平布局里的TextView和EditText按1:3分布,TextView文字右对齐2、 第二个水平布局的Button和TextView按1:3分布3、 第三个和第四个水平布局里的组件均为平均分布效果图勉5554:avd4.3々■3:36TvllIvqiyacmessagehelloIgetmessagehelloOredgreenObluefirst/second『thirdcol0r:greensequ&ncesecondjthirdj四、实验步骤:(含开发环境调试的截图、程序代码)1.布局Layout代码<?xmlversion="1.0"encoding="utf-8”?><RelativeLayoutxmlns:android="/apk/res/android"xmlns:tools="/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.administrator.zdf.MainActivity"><LinearLayoutandroid:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_alignParentTop="true”android:layout_centerHorizontal="true"android:weightSum="1"><LinearLayoutandroid:orientation="horizontal"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_gravity="center_horizontal"android:layout_weight="0.13"android:weightSum="1"><TextViewandroid:layout_width="111dp"android:layout_height="fill_parent"android:id="@+id/textView”android:gravity="center_vertical|right"/><EditTextandroid:layout_width="wrap_content”android:layout_height="fill_parent"android:id="@+id/editText”android:layout_weight="1”android:autoText="false”android:gravity="left"/></LinearLayout><LinearLayoutandroid:orientation="horizontal”android:layout_width="match_parent”android:layout_height="wrap_content”android:layout_gravity="center_horizontalandroid:layout_weight="0・13”><Buttonandroid:layout_width="wrap_content”android:layout_height="wrap_content”android:text="getmessage”android:layout_weight="1”<TextViewandroid:layout_width="wrap_content”android:layout_height="32dp”android:text="NewText"android:layout_weight="3"android:id="@+id/textView2”/></LinearLayout><LinearLayoutandroid:orientation="horizontal"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_gravity="center_horizontalandroid:layout_weight="0.13"><RadioGroupandroid:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="horizontal"android:id="@+id/rg"><RadioButtonandroid:layout_width="wrap_contentandroid:text=buleandroid:layout_weight="1"android:id="@+id/radioButton”android:checked="false"/><RadioButtonandroid:layout_width="wrap_contentandroid:layout_height="fill_parentandroid:text="black”android:id="@+id/radioButton2”android:layout_weight="1”android:checked="false"/><RadioButtonandroid:layout_width="wrap_contentandroid:layout_height="fill_parentandroid:text="red”android:layout_weight="1”android:id="@+id/radioButton3”android:checked="false"/></RadioGroup><LinearLayoutandroid:orientation="horizontal”android:layout_width="match_parent”android:layout_height="wrap_content”android:layout_gravity="center_horizontalandroid:layout_weight="0・13”><CheckBoxandroid:layout_width="wrap_content”android:layout_height="match_parentandroid:text="first”android:layout_weight="1”android:id="@+id/checkBox”android:checked="false”/><CheckBoxandroid:layout_width="wrap_content”android:layout_height="match_parentandroid:text="second”android:layout_weight="1”android:id="@+id/checkBox2”android:checked="false”/><CheckBoxandroid:layout_width="wrap_content”android:layout_height="match_parentandroid:text="third”android:layout_weight="1”android:id="@+id/checkBox3”android:checked="false”/></LinearLayout><TextViewandroid:layout_width="wrap_content”android:layout_height="wrap_content”android:text="color”android:id="@+id/textView3”android:layout_weight="0.13”/><TextViewandroid:layout_width="wrap_content”android:layout_height="wrap_content”android:text="sequence”android:id="@+id/textView4”android:layout_weight="0.13”/></RelativeLayout>2.activity代码packagecom.example.administrator.zdf;import.Uri;importandroid.support.v7.app.AppCompatActivity;importandroid.os.Bundle;importandroid.view.View;importandroid.widget.CheckBox;importandroid.widget.CompoundButton;importandroid.widget.EditText;importandroid.widget.RadioButton;importandroid.widget.RadioGroup;importandroid.widget.TextView;importcom.google.android.gms.appindexing.Action;importcom.google.android.gms.appindexing.AppIndex;importmon.api.GoogleApiClient;publicclassMainActivityextendsAppCompatActivityimplementsView.OnClickListener{privateEditTexteditText;privateTextViewtextView;privateTextViewtextView3;privateTextViewtextView4;privateRadioGrouprg;privateRadioButtonr1;privateRadioButtonr2;privateRadioButtonr3;privateCheckBoxm1;privateCheckBoxm2;privateCheckBoxm3;privateStringmyresult="”;/***ATTENTION:Thiswasauto-generatedoimplementtheAppndexingAPI.*Seehttps://g.co/AppIndexing/AndroidStudioformoreinformation*/privateGoogleApiClientclient;protectedvoidonCreate(BundlesavedInstanceState)(super.onCreate(savedInstanceState);setContentView(R.layout.activity_maii);findViewById(R.id.button).setOnClickListener(this);editText=(EditText)findViewById(R.id.editText);textView=(TextView)findViewById(R.id.textView2);textView3=(TextView)findViewById(R.id.textView3);textView4=(TextView)findViewById(R.id.textView4);rg=(RadioGroup)findViewById(R.id.rg);r1=(RadioButton)findViewById(R.id.radioButto);r2=(RadioButton)findViewById(R.id.radioButton);r3=(RadioButton)findViewById(R.id.radioButton);m1=(CheckBox)findViewById(R.id.checkBox);m2=(CheckBox)findViewById(R.id.checkBox2);m3=(CheckBox)findViewById(R.id.checkBox3);m1.setOnCheckedChangeListener(CheckedChangeListener);m2.setOnCheckedChangeListener(CheckedChangeListener);m3.setOnCheckedChangeListener(CheckedChangeListener);rg.setOnCheckedChangeListener(newRadioGroup.OnCheckedChangeListener()(©OverridepublicvoidonCheckedChanged(RadioGroupgroup,intcheckedId)(if(R.id.radioButton==checkedId)(textView3.setText("color:"+r1.getText().toString());}elseif(R.id.radioButton2二二checkedId)(textView3.setText("color:"+r2.getText().toString());textView3.setText("color:"+r3.getText().toString());}}});}privateCompoundButton.OnCheckedChangeListenerCheckedChangeListener二newCompoundButton.OnCheckedChangeListener()(©OverridepublicvoidonCheckedChanged(CompoundButtonbuttonView,booleanisChecked)(if(m1.isChecked())(myresult二myresult+m1.getText().toString()+"\t”;}if(m2.isChecked()){myresult二myresult+m2.getText().toString()+"\t”;}if(m
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 兼职工作合同协议
- 消防系统检测合同
- 小数的意义(教学设计)-2023-2024学年四年级下册数学人教版
- 管理软件系统购买合同范文格式7篇
- 吨的认识(教学设计)-2024-2025学年三年级上册数学人教版
- 双手胸前传接球 教学设计-2023-2024学年高二下学期体育与健康人教版必修第一册
- 小学三年级数学几百几十加减几百几十水平练习习题
- 简易家用活动平台施工方案
- Unit 1 Lesson 3 The Sun Is Rising教学设计 -2024-2025学年冀教版八年级英语下册
- 第9课 两宋的政治和军事 教学设计-2023-2024学年高一上学期统编版(2019)必修中外历史纲要上
- 《中国商贸文化》3.1古代商人
- 南宋北京大学历史学系课件
- 重庆市房屋建筑与装饰工程计价定额2018-建筑工程
- 三年级数学-解决问题策略(苏教版)
- 不吃路边摊精品课件
- 《网络服务器搭建、配置与管理-Linux(RHEL8、CentOS8)(微课版)(第4版)》全册电子教案
- 心理评估与诊断简介
- 无痛病房管理课件
- 让孩子变成学习的天使——由《第56号教室的奇迹》读书分享
- 球泡检验标准
- 振动分析基础讲义1
评论
0/150
提交评论