资源描述
按一下以編輯母片標題樣式,按一下以編輯母片,第二層,第三層,第四層,第五層,*,*,*,单击此处编辑母版标题样式,单击此处编辑母版文本样式,第二级,第三级,第四级,第五级,*,*,MARKETING,*,单击此处编辑母版标题样式,单击此处编辑母版文本样式,第二级,第三级,第四级,第五级,Outline,W,hat is Android?,How to develop Android Application?,My first Android Application:HelloAndroid,11/13/2024,8,What is Android?,Android is a software stack for mobile devices that includes an operating system middleware and key applications.,The Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the,Java programming language,.,11/13/2024,9,W,hat is Android?,Android是一個基於Linux kernel的智慧型手機作業系統。,Android是免費且開放的手機開發平台。,Android應用程式開發使用Java(類似J2ME),應用程式的使用者介面則使用XML,規劃 設計。,LinuxGoogle的連鎖反應Android,11/13/2024,10,Android Architecture,11/13/2024,11,How to develop Android Application?,Install Android development tools.,JDK5 or JDK6,Eclipse IDE,Android SDK,ADT(Android Develop Tools plugin),Using the Eclipse I,DE to program Android Application.,11/13/2024,12,Eclipse IDE,1.Download Eclipse,11/13/2024,13,Eclipse IDE,將,Eclipse解壓縮到適當的位置即可,進入Eclipse畫面,設定workspace,11/13/2024,14,Android SDK1.5,到Android官方網站下載,Android SDK,developer.android/sdk/index.html,11/13/2024,15,Android SDK,解壓縮後,放到適當位置即可,設定Android SDK tools環境變數、工作路徑,Vi/.bash_procfile,,,修改完後重新開機或登錄,11/13/2024,16,在Path中加入Android SDK tools目錄的工作路徑,11/13/2024,17,Eclipse中,選擇工作列,Window,Preferences,選擇Android,設定Android SDK的工作路徑,11/13/2024,18,選擇Android 1.5,按下Apply,OK即可,11/13/2024,19,ADT(Android Develop Tools plugin),我們要在Eclipse IDE上安裝Android工具擴充套件,在Eclipse中,選擇,HelpInstall new Software,11/13/2024,20,dl-ssl.google/android/eclipse,ADT,11/13/2024,21,全選Developer Tools中的選項,按下Next,依序安裝完成後,會重新啟動Eclipse,即完成安裝,11/13/2024,22,My first Android Application:HelloAndroid,執行Eclipse,,NewProjectAndroid Project,按下Next,11/13/2024,23,New Android Project,11/13/2024,24,Android程式目錄架構,主程式,資源檔,字元檔,圖片檔,主佈局檔,11/13/2024,25,主程式類別HelloAndroid.java,11/13/2024,26,R.java:Resource Index,11/13/2024,27,Android的R類別,R.java是由Android Development Kit所自動產生的資源索引檔,R.layout類別則是UI佈局的索引類別,R.layout類別裡的main成員就是Android應用程式的主佈局索引,11/13/2024,28,Activity類別,package,edu.yuntech.mocis;,import,android.app.Activity;,import,android.os.Bundle;,import,android.widget.TextView,;,public,class,HelloAndroid,extends,Activity,/*Called when the activity is first created.*/,Override,public,void,onCreate(Bundle savedInstanceState),super,.onCreate(savedInstanceState);,setContentView(R.layout.,main,);,11/13/2024,29,Android的Activity,與使用者互動的物件,負責建立視窗,透過View放置UI,Activity在foreground執行,11/13/2024,30,Create AVD,11/13/2024,31,Run Configurations,11/13/2024,32,Run Android Virtual Device,11/13/2024,33,執行結果,11/13/2024,34,Run Configurations 2,11/13/2024,35,Run Configurations 2,11/13/2024,36,修改main.xml,使用android:autoLink屬性控制可已自動把網址轉換成可點擊的URL文字,使用autoLink屬性,並將此屬性設定為web即可做出我們想要的功能,11/13/2024,37,修改main.xml,11/13/2024,38,執行結果,11/13/2024,39,執行結果,11/13/2024,40,HelloAndroid-2,public,class,HelloAndroid,extends,Activity,/*Called when the activity is first created.*/,Override,public,void,onCreate(Bundle savedInstanceState),super,.onCreate(savedInstanceState);,TextView tx=new TextView(this);,tx.setText(”Hello,Android!”);,setContentView(tx);,11/13/2024,41,Android Reference,11/13/2024,42,Android程式設計的特點,Activity/Service,main.xml,View,AndroidManifest.xml描述Android應用程式,11/13/2024,43,Android UI設定View,手機的UI,View負責繪製UI與處理事件(event),Android應用程式的UI從程式碼的角度來看,就是一顆view tree,可以利用直接撰寫程式碼,或是透過XML.layout檔的方式,來安排應用程式的view tree,11/13/2024,44,再见,
展开阅读全文