close

step  1.  先建一個新專案


命名

(因為已經建好了,再示範一次所以有叉叉)

 



 

 

 

step 2.  開始來寫程式了

layout點右鍵->other

點選Android XML Layout File

 

命名為linear

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

程式碼:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:orientation="vertical" >
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint=
"@string/to" />

//新增的字串
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint=
"@string/subject" />

//新增的字串
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:gravity="top"
        android:hint=
"@string/message" />

//新增的字串
    <Button
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_gravity="end"
        android:text=
"@string/send" />

//新增的字串

</LinearLayout>\

 

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src
決定要執行的 layout頁面,可以同時寫不同的頁面
但是執行的時候選其中一種

 

點選values裡的string

修改string,增加string變數

 

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

程式碼:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="app_name">FirstEx</string>
    <string name="hello_world">Hello world!</string>
    <string name="to">To</string>
    <string name="subject">Subject</string>
    <string name="message">Message</string>
    <string name="send">Send</string>
    

</resources>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

step 3.  開始來跑程式了

BMI project按右鍵,點選 Run As->Android Application

 



顯示結果






 

arrow
arrow
    文章標籤
    Android
    全站熱搜

    布拉怡 發表在 痞客邦 留言(0) 人氣()