Android 2.2 r1 API 中文文檔系列(12) —— Button

前言
 html

  截止到這篇,總共翻譯了Android API十二篇,其中有兩篇是翻譯組另一名成員提供。翻譯工做量雖大、雖難,但無論是對本身仍是對別人都是巨大的幫助,少則一篇不嫌少,多則十篇不嫌多,再次呼籲你們的熱心參與Android api 中文翻譯,個人郵箱over140@gmail.com。
 java


 

聲明android

  歡迎轉載,但請保留文章原始出處:)
 api

    農民伯伯:http://over140.blog.51cto.com/ide

 

正文佈局

  1、結構學習

    public class Button extends TextView

    java.lang.Object
        android.view.View
              android.widget.TextView
                    android.widget.Buttonui

 

    已知直接子類
      CompoundButton

    已知間接子類
      CheckBox, RadioButton, ToggleButtonspa

 

  2、概述
 .net

    

    表明一個按鈕部件。用戶經過按下按鈕,或者點擊按鈕來執行一個動做。如下是一個按鈕在activity中典型的應用:

    

    而後,你能在xml佈局中經過button的android:onClick屬性指定一個方法,以替代在activity中爲button設置OnClickListener。例如:

    

    如今,當用戶點擊按鈕時,Android系統調用activity的selfDestruct(View)方法。爲了正確執行,這個方法必須是public而且僅接受一個View類型的參數。例如:

    

  
 

  3、按鈕樣式
 

  每一個按鈕的樣式默認爲系統按鈕的背景,不一樣的設備、不一樣的平臺版本有不一樣按鈕風格。如你不滿意默認的按鈕樣式,想對其定製以符合您應用程序的設計,那麼你能用state list drawable替換按鈕的背景圖片。一個狀態列表drawable是一個在XML中定義的drawable資源,根據當前按鈕的狀態改變其圖片。一旦你在XML中定義了一個狀態列表drawable,你能夠將它應用於你的android:background屬性。欲瞭解更多信息和示例,參見State List Drawable.

實現一個按鈕的例子可參見Form Stuff tutorial

 

 

  4、XML屬性

    參見ButtonTextViewViewXML屬性。

 

  5、下載

    CSDN: http://download.csdn.net/source/2739376

 

  6、系列
 

    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

 

結束
 

   取之於網上中文資料學習,饋之於網上而供他人學習。  

相關文章
相關標籤/搜索