版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 通信移动终端设备装调工安全宣贯水平考核试卷含答案
- 民族拉弦弹拨乐器制作工岗前岗中技能考核试卷含答案
- 物联网安装调试员岗前压力管理考核试卷含答案
- 铝电解操作工岗前客户服务考核试卷含答案
- 医用材料产品生产工岗前基础安全考核试卷含答案
- 数控车工岗前岗中考核试卷含答案
- 染色小样工操作技能强化考核试卷含答案
- 2026年小学成语故事《古稀之年》文化常识教学设计教案
- 2026年小学成语故事《大器晚成》成长教育课堂教案
- 临床医学检验技术相关专业知识模拟卷
- 2026年甘肃省兰州新区产投资本控股集团有限公司招聘考试备考试题及答案详解
- 2026年秋季西师大版小学一年级上册数学教学计划
- 新版2025-2026部编人教版小学语文1一年级上册(全册)教案设计合集
- 基层医疗卫生机构慢性病健康管理中心建设与服务指南(2026年)
- 2026秋季小学生开学第一课
- (2026秋新版)苏教版六年级数学上册全册教案
- 2026年广东省中考数学试卷(含详细答案解析)
- 新学期(2026年秋)高中班主任工作计划
- 2026监理员继续教育考试题库及答案
- 2026年金融专业测试题目及答案
- 工程材料检测方案
评论
0/150
提交评论