Visual 程序的設計教程第16章_第1頁
Visual 程序的設計教程第16章_第2頁
Visual 程序的設計教程第16章_第3頁
Visual 程序的設計教程第16章_第4頁
Visual 程序的設計教程第16章_第5頁
已閱讀5頁,還剩9頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、2021-11-8216.1 textview文本框wtextview 是用于顯示字符串的組件,對于用戶來說就是屏幕中一塊用于顯示文本的區(qū)域。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、可以在代碼中動態(tài)創(chuàng)建,其工程保存在目錄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 兩種實現(xiàn)方式,在xml和代碼中都可以實現(xiàn),但相比較而言,在xml中實現(xiàn)更有利于代碼的改動。其

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:持續(xù)顯示視圖或文本提示較長時間。該時間長度可定制。參見setduration(int);w

8、常量length_short:持續(xù)顯示視圖或文本提示較短時間。該時間長度可定制。該值為默認值。參見setduration(int);2021-11-810 16.5.3 toast類的方法w 16.5.4 toast類的使用類的使用w 接下來的示例要實現(xiàn)的是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的結構、屬性、方法及其使用,并提供了創(chuàng)建好的工程文件,讀者可以直接使用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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論