版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 重症医学科心源性休克护理要点
- 西藏拉萨市10校2025-2026学年化学高二上期末学业质量监测模拟试题含解析
- 云南省保山市施甸县一中2025-2026学年高二物理第一学期期末质量检测试题含解析
- 神经科小儿脑膜炎治疗方案
- 六盘水职业技术学院《有机化学(Ⅰ)(2)》2024-2025学年第一学期期末试卷
- 重症医学科ICU创伤性颅脑损伤监护护理规范
- 神经科帕金森病治疗方案
- 癫痫患者药物治疗领域及副作用培训
- 肠道感染预防控制流程
- 急性胰腺炎支持性治疗措施
- 情境交互设计:为生活而设计
- 闪耀明天 二声部合唱简谱
- 淇滨区交通路政管理所路政巡查情况记录表、统计表
- 基于课程标准的教学评一致性课堂教学评价
- 美术作品与客观世界 课件-2023-2024学年高中美术湘美版(2019)美术鉴赏
- 2022年浙江公务员考试行测真题及答案(B卷)
- 管线的悬吊保护方案
- 行政执法资格考试题库及答案
- 钢铁集团技术创新项目办法(完整版)资料
- 2022年新入路青工背规竞赛通识题库全员版
- GB 14648-1993民用航空器飞行事故等级
评论
0/150
提交评论