Visual 程序的设计教程第16章_第1页
Visual 程序的设计教程第16章_第2页
Visual 程序的设计教程第16章_第3页
Visual 程序的设计教程第16章_第4页
Visual 程序的设计教程第16章_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

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

文档简介

1、2021-11-8216.1 textview文本框wtextview 是用于显示字符串的组件,对于用户来说就是屏幕中一块用于显示文本的区域。textview类的层次关系如下:w java.lang.objectw android.view.vieww android.widget.textviewhttp:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ htt

2、p:/ http:/ http:/ http:/www.xunchi- http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ textview的使用的使用w 可以在xml布局文件中声明及设置textview,也可以在代码中生成textview组件。本小结代码保存在目录eg16_1中。http:/ http:/ http:/ http:/ http:/ http:/ htt

3、p:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/www.xunchi- http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ edittext编辑框edittext

4、类的结构 edittext类的方法 edittext标签的属性 edittext的使用2021-11-8516.3 button按钮w 16.3.1 button类的结构类的结构w 16.3.2 button类的常用方法类的常用方法button类的常用属性语言符号 由于button是继承textview,所以textview有的属性,它都能用。除此之外,button类还具有一些textview不具备的属性。button类的其他属性如表16.6所示。http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http

5、:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/www.xunchi- http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ c+ 程序设计教程第2章6w button类的使用类的使用w button可以在xml中声明,也

6、可以在代码中动态创建,其工程保存在目录eg16_3中。2021-11-8visual c+ 程序设计教程第2章7 16.4 imagebutton图片按钮图片按钮 16.4.1 imagebutton类的结构w 16.4.2 imagebutton类的常用方法类的常用方法w imagebutton类的常用方法如表16.7所示。w 16.4.3 imagebutton类的常用属性类的常用属性w imagebutton类的常用属性如表16.8所示。w 16.4.4 imagebutton类的使用类的使用w 两种实现方式,在xml和代码中都可以实现,但相比较而言,在xml中实现更有利于代码的改动。其

7、工程代码保存在eg16_4中。2021-11-8816.5 toast提示提示w 16.5.1 toast类的结构类的结构w toast是android提供的“快显讯息”类,它的用途很多,使用起来非常的简单。它是直接继承java.lang.object的。因此它的类层次结构如下:w java.lang.objectw android.widget.toast2021-11-89w 16.5.2 toast的常量的常量w toast中有两个关于toast显示时间长短的常量:w 常量length_long:持续显示视图或文本提示较长时间。该时间长度可定制。参见setduration(int);w

8、常量length_short:持续显示视图或文本提示较短时间。该时间长度可定制。该值为默认值。参见setduration(int);2021-11-810 16.5.3 toast类的方法w 16.5.4 toast类的使用类的使用w 接下来的示例要实现的是toast的直接显示以及toast显示view的内容,其工程代码保存在目录eg16_5中。2021-11-81116.6 linearlayout线性布局线性布局w 16.6.1 线性布局介绍线性布局介绍w linearlayout是一种线性排列的布局,在线性布局中,所有的子元素都按照垂直或水平的顺序在界面上排列。w 16.6.2 线性布局

9、的常用属性线性布局的常用属性w android:id:为控件指定相应的id;w android:text:指定控件当中显示的文字,需要注意的是,这里尽量使用strings.xml文件当中的字符;http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/www.xunchi- http:/ http:/ htt

10、p:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ 16.6.3 线性布局常用的方法线性布局常用的方法w 线性布局的常用方法如表16.9所示。w 16.6.4 线性布局的使用线性布局的使用w 在xml中设置如下,其工程代码保存在目录eg16_6下。 2021-11-81316.7 relativelayout相对布局w 16.7.1 relativelayout类的结构类的结构w 相对布局(relati

11、velayout)是一种非常灵活的布局方式,能够通过指定界面元素与其他元素的相对位置关系,确定界面中所有元素的布局位置。w 16.7.2 relativelayout类的常用方法类的常用方法w relativelayout类的常用方法如表16.10所示。 16.7.3 relativelayout类的常用属性类的常用属性w 16.7.4 relativelayout类的使用类的使用w relativelayout示例的工程代码保存在目录eg16_7中。http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ ht

12、tp:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/www.xunchi- http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ 16.8 小结小结w 本章主要介绍了android sdk中提供的一些常用控件,包括textview、edittext、button、imagebutton、toast、linearlayout和relativelayout的结构、属性、方法及其使用,并提供了创建好的工程文件,读者可以直接使用eclipse导入并运行、调试,加以学习。http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http:/ http

温馨提示

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

最新文档

评论

0/150

提交评论