




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 西 安 邮 电 大 学(计算机学院)课内实验报告实验名称: 界面设计:布局管理器 专 业: 网络工程 班 级: 姓 名: 学 号: 指导教师: 日 期: 2017年5月4日一实验目的1. 了解四种布局管理器的区别和各自特别的属性2. 掌握四种布局管理器的应用场合和用法 3. 灵活使用四种布局文件管理器和嵌套实现各种复杂布局4. 掌握复用XML布局文件的方法5. 掌握代码控制UI界面的方法二实验环境JDK的版本: "1.8.0_40"IDE: eclipse 4.6.1模拟器: 夜神模拟器三实验内容设计的样式,完成Android应用UI的应用开发四实验过程及分析1.用JAV
2、A代码设置全屏打开工程src目录下的主Activity文件,在onCreate方法中的执行语句super. onCreate(savedInstanceState)之前,添加如下两句语句requestWindowFeature(Window.FEATURE_NO_TITLE); /隐藏标题栏this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); /隐藏运营商图标、电量等2. 按照图1设计的样式,完成一个Android应用UI
3、的开发(1)添加代码<LinearLayout xmlns:android=" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <ImageView android:id="+id/imageView1" android:layout_width="350dp" android:layout_height=
4、"100dp" android:src="drawable/ic_launcher4" /> <LinearLayout android:layout_width="match_parent" android:layout_height="76dp" android:layout_marginTop="14dp" android:orientation="horizontal" > <ImageView android:layout_width=&qu
5、ot;100dp" android:layout_height="100dp" android:src="drawable/ic_launcher1" /> <TableLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" > <TableRow android:layout_width=&
6、quot;wrap_content" android:layout_height="wrap_content" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="账号:" /> <EditText android:id="+id/userName" android:layout_width="120dp&q
7、uot; android:layout_height="wrap_content" /> </TableRow> <TableRow android:layout_width="wrap_content" android:layout_height="wrap_content" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android
8、:text="密码:" /> <EditText android:id="+id/userPass" android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="textPassword" > <requestFocus /> </EditText> </TableRow> </TableLayout> &l
9、t;/LinearLayout> <Button android:layout_width="156dp" android:layout_height="28dp" android:layout_gravity="center" android:layout_marginBottom="10dp" android:layout_marginTop="20dp" android:background="#333" android:onClick="logi
10、n" android:text="登录" android:textColor="#FFF" /> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:text="记住密码" /> <CheckBox android:layout_width=&quo
11、t;wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:text="自动登录" /> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" andr
12、oid:text="接收产品推广" /> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="12dp" > <Button android:layout_width="124dp" android:layout_height="34dp" android:layout_margin
13、Left="160dp" android:background="#333" android:onClick="forgetPass" android:text="忘记密码" android:textColor="#FFF" /> <Button android:layout_width="124dp" android:layout_height="34dp" android:layout_marginLeft="30dp"
14、 android:background="#333" android:onClick="register" android:text="注册账号" android:textColor="#FFF" /> </FrameLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="63dp" android:orientation="vertic
15、al" > <TextView android:id="+id/loading" android:layout_width="match_parent" android:layout_height="wrap_content" /> <ProgressBar style="?android:attr/progressBarStyleSmall" android:layout_width="match_parent" android:layout_height=&
16、quot;30dp" android:layout_marginBottom="10dp" /> </LinearLayout></LinearLayout>(2)查看布局效果3. 在主Activity文件中,添加用于登录的Login方法用于处理忘记密码的forgetPass方法、用于注册界面Register方法,(1)在MainActivity类中添加登录、忘记密码、注册密码的时间监听程序public void login(View view)if( check() )StringBuilder sb = new StringBui
17、lder();sb.append("登录成功!"+"n");sb.append("用户名:" + userName.getText().toString()+"n");sb.append("密码:" + userPass.getText().toString()+"n");Toast.makeText(this, sb.toString(), Toast.LENGTH_LONG).show();Intent intent = new Intent(); /登录到ResultA
18、ctivity页面intent.setClass(this, ResultActivity.class);intent.putExtra("info", sb.toString();this.startActivity(intent);/打开忘记密码界面public void forgetPass(View view)StringBuilder sb = new StringBuilder();Intent intent = new Intent(); /忘记密码到PassActivity页面intent.setClass(this, PassActivity.class)
19、;intent.putExtra("info", sb.toString();this.startActivity(intent);/打开注册界面public void register(View view)StringBuilder sb = new StringBuilder();Intent intent = new Intent(); /注册到RegisterActivity页面intent.setClass(this, RegisterActivity.class);intent.putExtra("info", sb.toString();t
20、his.startActivity(intent);该类的布局如下图:(2)创建登录后的类ResultActivity,对于对于MainActivity传来的数据进行显示protected void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.activity_result);TextView result = (TextView)findViewById(R.id.result);result.se
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- GB/T 45536-2025感官分析实验室质量控制指南
- GB/T 45575-2025工业产品表面缺陷自动检测系统技术要求
- 2025年计算机:IT.程序员职业技能资格知识考试题与答案
- 主题婚礼策划与流程
- 全科医学转岗培训课件
- 宣传信息工作培训
- 个人能力培训教程课件
- 物业安全人员岗前培训
- 园林景观设计与施工培训课件
- 车辆维修报账合同协议
- GA/T 1556-2019道路交通执法人体血液采集技术规范
- 作业现场安全监督检查卡(配电)
- 幼儿园绘本故事:《小熊不刷牙》
- 安全生产会议记录(12个月)
- 旅行管家实务全套ppt课件最全电子教案完整版教学教程整套全书课件ppt
- 做好孩子的引路人课件
- 丽声北极星分级绘本第一级上My Noisy Schoolbag教学设计
- (完整版)管理经济学题库
- 毕业设计粗饲料粉碎机的设计全套CAD图纸
- 植物基酸奶项目说明(范文模板)
- 钣金报价计算表(强)
评论
0/150
提交评论