android: button 屬性

來源:互聯網
上載者:User

標籤:android   style   color   使用   io   檔案   ar   代碼   

代碼中常用屬性:

Button bt=new Buttion(Context context);

setClickable(boolean clickable)

設定按鈕是否允許點擊。

clickable=true:允許點擊

clickable=false:禁止點擊

setBackgroundResource(int resid)

通過資源檔設定背景色。

resid:資源xml檔案ID。

按鈕預設背景為:android.R.drawable.btn_default

setText(CharSequence text) 設定按鈕顯示文字。
setTextColor(int color)

設定按鈕顯示文字的顏色。

color可以使用系統Color常量,例如 Color.BLACK等。

setOnClickListener(OnClickListener l) 設定按鈕點擊事件
   

 

xml中常用屬性:

android:layout_width=""---控制項寬

android:layout_height=""---控制項高

android:layout_weight=""---控制項權重

android:text=""---控制項上的常值內容

android:onClick="doClick"---點擊此控制項時調用的方法---方法名稱為:doClick

android:drawableTop=""---在Button組件上放置圖片

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.