Android的一些方法和屬性

來源:互聯網
上載者:User

標籤:edittext   com   size   布局檔案   content   src   utf-8   raw   near   

1.Activity常用的方法
  View findViewById(int id)//根據組件的ID取得組件對象
  setContentView(int layoutResID)//設定布局檔案,設定顯示組件


2.TextView
  android:maxLength="6"//允許最大字元數
  android:textColor="#FF0000"//文字的顏色
  android:textSize="50px"//文字的大小
  android:textStyle="bold"//文字樣式
  android:password="true"//是否以密文方式顯示
  android:layout_margin="50px"//外邊距
  android:background="@drawable/p"//背景
  android="@+id/id值"//設定id的值

  getText().toString();//獲得控制項的常值內容
  setText();//設定控制項的常值內容
  注意:<!-- -->:注釋


3.Button


4.EditText
  android:enabled="false"//設定是否可用,false不能用

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    >    <!-- <TextView      android="@+id/tv"    android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:text="Second123"    android:maxLength="6"    android:textColor="#FF0000"    android:textSize="50px"    android:textStyle="bold"    android:password="true"    android:layout_margin="50px"    android:background="@drawable/p"    />     -->         <!-- prefix:首碼  --> <TextView      android="@+id/tv2"    android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:text="Second123"    android:maxLength="9"    android:textColor="#00FF00"    android:textSize="50px"    android:textStyle="bold"    android:password="true"    /><Button    android:layout_width="fill_parent"    android:layout_height="wrap_content"    android:text="按鈕"    android:textColor="#FF0000"/><EditText    android:layout_width="fill_parent"    android:layout_height="wrap_content"    android:text="我是好人"    android:enabled="false"/></LinearLayout>
範例程式碼

 

Android的一些方法和屬性

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.