December 10, 2012

android 第一隻程式 hello world

學習程式語言第一個會寫的就是hello world

透過eclipse新增project hello world瞬間就完成了

選取File->New->Android Application Project
 
輸入
application name  --使用者在程式清單上看到的名字
project name        --程式開發者在eclipse中看到project的名字
package name     --整個package的名字

下面選擇sdk的部份先用default就好
 

接著對話視窗出現如下圖示
可以指定程式碼要放置的路徑 



簡易的圖示產生器
可以用文字 圖片 與他內建的背景做結合 調整顏色等
調整好後next


eclipse提供基本預設版型
右邊有預覽畫面
這裡選擇blankActivity
 

可以輸入activity/layout名字
finish完成建置


自動產生的android project結構如下
src   程式碼
gen  程式自動產生的檔案
assets  附加的檔案
bin   輸出檔案
libs   函式庫
res    資源碼
    drawable    圖檔資源
    layout       擺設架構
    value        文字 數值
androidManifest.xml 描述android app整體資訊的設定檔


有了程式碼 在開始測試前先設定模擬器
於window->android virtual device manager
 

新增


輸入模擬器名稱
選擇android 版本/銀幕解析度 完成 

 

選擇剛剛新增的模擬器  start


開啟模擬器畫面

 
找到run按鈕
開始測試程式碼所呈現的結果

 
程式執行結果 

 
原始碼下載
https://docs.google.com/open?id=0B32Hg7Y7T6pTOUp4T1J0NzFQcTg

 
 

0推薦此文章
Today's Visitors: 0 Total Visitors: 6
Personal Category: android Topic: technology / tech info / programming
Previous in This Category: android setup 環境設置   Next in This Category: android 抓取ip tortual

誰來收藏
Loading ...
unlog_NVPO 0