[ 專案架構(常用) ]
資料夾 src ==>class檔(.java)
res ==>資源檔
==>drawable(圖檔).layout(介面檔 .xml)
menu(選單 .xml).values(資源檔 可存放字串.顏色等..,.xml)
gen==>底下的一個R類別(R.java)
==>整合專案中的所有資源,編譯器會自動產生檔案,不要隨便修改
[ code ]
●class檔
package 套件名稱(路徑名);
import android.app.Activity;
import android.os.Bundle;
public class Name extends Activity{
@Override
public void onCreate (Bundle saveInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main); // 執行時開啟的介面檔
/* code */
}// onCreate
//建立選單,可留可不留,建檔自動附加
@Override
public boolean onCreateOptionsMenu(Menu menu) {
/* code */
return true;
}// onCreateOptionsMenu
}// class
●介面檔(.xml)
<介面元件
android:id=@+id/自訂元件名稱
android:屬性=”屬性值”
/>
Ex))
<Button
android:id="@+id/btOk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="確 定"
/>
常用屬性介紹
http://ooohomeooo.blogspot.tw/2012/03/android_02.html
請先 登入 以發表留言。