前言
截止到這篇,總共翻譯了Android API十二篇,其中有兩篇是翻譯組另外一名成員提供。翻譯工作量雖大、雖難,但不管是對自己還是對別人都是巨大的協助,少則一篇不嫌少,多則十篇不嫌多,再次呼籲大家的熱心參與Android api 中文翻譯,我的郵箱over140@gmail.com。
聲明
歡迎轉載,但請保留文章原始出處:)
部落格園:http://www.cnblogs.com
農民伯伯: http://www.cnblogs.com/over140/
本文
一、結構
public class Button extends TextView
java.lang.Object
android.view.View
android.widget.TextView
android.widget.Button
已知直接子類
CompoundButton
已知間接子類
CheckBox, RadioButton, ToggleButton
二、概述
代表一個按鈕組件。使用者通過按下按鈕,或者點擊按鈕來執行一個動作。以下是一個按鈕在activity中典型的應用:
然後,你能在xml布局中通過button的android:onClick屬性指定一個方法,以替代在activity中為button設定OnClickListener。例如:
現在,當使用者點擊按鈕時,Android系統調用activity的selfDestruct(View)方法。為了正確執行,這個方法必須是public並且僅接受一個View類型的參數。例如:
三、按鈕樣式
每個按鈕的樣式預設為系統按鈕的背景,不同的裝置、不同的平台版本有不同按鈕風格。如你不滿意預設的按鈕樣式,想對其定製以符合您應用程式的設計,那麼你能用state list drawable替換按鈕的背景圖片。一個狀態列表drawable是一個在XML中定義的drawable資源,根據當前按鈕的狀態改變其圖片。一旦你在XML中定義了一個狀態列表drawable,你可以將它應用於你的android:background屬性。欲瞭解更多資訊和樣本,參見State List Drawable.
實現一個按鈕的例子可參見Form Stuff tutorial
四、XML屬性
參見Button、TextView、View的XML屬性。
五、下載
CSDN: http://download.csdn.net/source/2739376
六、系列
Android 2.2 API 中文文檔系列(1) —— TextView
Android 2.2 API 中文文檔系列(2) —— EditText
Android 2.2 API 中文文檔系列(3) —— AccessibilityService
Android 2.2 API 中文文檔系列(4) —— Manifest
Android 2.2 API 中文文檔系列(5) —— View
Android 2.2 API 中文文檔系列(6) —— ImageView
Android 2.2 API 中文文檔系列(7) —— ImageButton
Android 2.2 API 中文文檔系列(8) —— QuickContactBadge
Android 2.2 API 中文文檔系列(9) —— ZoomButton
Android 2.2 r1 API 中文文檔系列(10) —— CheckBox
Android 2.2 r1 API 中文文檔系列(11) —— RadioButton
結束
取之於網上中文資料學習,饋之於網上而供他人學習。