html5-img
1 / 68

Course 04

Course 04. Android 現況概述. 進一步介紹開發環境. 開發環境介紹與熟悉. Emulator. Debug Tools. 程式基本框架介紹. 建立第一個 App – BMI. Demo Code. Plan & Design. 開發演練. Coding- UI 描述 與設計. 程式流程解讀. 與使用者對話 - Dialog. Activities & Intent. 進階應用介紹. Data Storage. 多媒體 - 圖片與聲音. 後續延伸 -Web Service. 0. 關於本堂課. Emulator ?

bryson
Download Presentation

Course 04

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Course 04

  2. Android 現況概述 進一步介紹開發環境 開發環境介紹與熟悉 Emulator Debug Tools 程式基本框架介紹 建立第一個App – BMI Demo Code Plan & Design 開發演練 Coding- UI描述 與設計 程式流程解讀 與使用者對話- Dialog Activities & Intent 進階應用介紹 Data Storage 多媒體-圖片與聲音 後續延伸-Web Service

  3. 0.關於本堂課 • Emulator ? • 更進一步介紹開發環境,實際練習操作指令 • BUG and Debug

  4. Emulator • 為什麼需要模擬器? • 方便開發 • 特定情況下,可透過模擬器模擬(EX: 兩支手機) • 啟動與使用 Android 模擬器 • 更改模擬器的設定-外觀,方向切換 • 練習: Emulator's Communication Reference: http://developer.android.com/guide/developing/tools/emulator.html

  5. ADB (android debug bridge) • 甚麼是adb ? • 相關指令: • 檔案檢視-ls • 將檔案上傳到模擬器- adb push 001.jpg /sdcard • 將檔案從模擬器上下載 -adb pull /sdcard/001.jpg • 刪除檔案 rm xxx.jpg • SD Card Create and Mount-mksdcard 1024M sdcard.img • 建立模擬器 • 操作模擬器 • 安裝apk

  6. 關於BUG Bug Developers

  7. Debug-Android 提供的Debug 環境 • Debug View • 設定/觀察中斷點 • 留Log : Logcat • Logcat with Console monitor • TraceView

  8. 開發工具簡介- DDMS • 透過DDMS 模擬手機的各種狀況 • try:傳簡訊 • try:打電話 • Reference : http://code.google.com/intl/zh-TW/android/reference/ddms.html

  9. REFERENCE: • Debug Tasks • android/docs/guide/developing/debug-tasks.html • Logcat • http://developer.android.com/intl/zh-TW/guide/developing/tools/adb.html#logcat • Filtering Log Output • Controlling Log Output Format • 輔助開發工具-OpenIntents: • http://code.google.com/p/openintents/wiki/SensorSimulator • 使用 Android 虛擬機器 • http://code.google.com/p/androidbmi/wiki/PlayEmulator • ADB 指令: • http://developer.android.com/intl/zh-TW/guide/developing/tools/adb.html

  10. Android 現況概述 進一步介紹開發環境 開發環境介紹與熟悉 Emulator Debug Tools 程式基本框架介紹 建立第一個App – BMI Plan & Design 開發演練 Pratice01- UILayOut Pratice02-完成程式邏輯 Pratice03-進行重構 Pratice04-Menu,Dialog 進階應用介紹 Pratice05-Activities & Intent Pratice06-Data Storage Pratice07-圖片與動畫

  11. 怎麼做一個 App? Reference : http://whoswho.openfoundry.org/workshop/details/61-kalug--android-.html

  12. 今日目標- • 完成一個簡單的應用程式 • Weight / BMI 計算器 • 參考來源: • http://sites.google.com/site/gasodroid/Home/androidentry3

  13. BMI ? • 身高體重指數(又稱身體質量指數,英文為Body Mass Index,簡稱BMI)是一個計算值,主要用於統計用途。當我們需要比較及分析一個人的體重對於不同高度的人所帶來的健康影響時,BMI值是一個中立而可靠的指標

  14. Plan - 想法 • 輸入身高與體重,輸出BMI值,以及建議 • 記下每天的體重 • 可以設定目標,決定日期與目標體重,在每天輸入時,告訴我一些建議 • 提醒功能: 顯示一個小機器人,變胖時跟著變胖,變瘦時跟著變瘦,同時發出鼓勵/沮喪的音效 • 提醒功能: 透過提醒列,提醒我 • 監督功能: 如果一直過重超過xx天 ,自動送出簡訊(SMS)告訴朋友 • 跟網路服務同步 • anything else ?

  15. 先完成Prototype: • 輸入身高與體重,取得BMI值的建議 • 顯示結果,以及建議 • 調整顯示內容的方式 • 資料儲存 • 動畫顯示

  16. 針對目標,我們要做的事: • 需求分析 • 輸入 • 體重 • 身高 • 輸出 • BMI結果 • 建議 • LayOut- 介面設計, UI 決定, 操作方式決定 • 各種可用介面元件列表 • http://developer.android.com/guide/tutorials/views/index.html • Edit Text • http://developer.android.com/intl/zh-TW/reference/android/widget/EditText.html • Get/setText method • EditText Attributes • android:numeric • TextView • Button • 開始Coding

  17. 針對目標,我們要做的事: • 需求分析 • 輸入 • 體重(EditText) • 身高(EditText) • 輸出 • BMI結果((TextView) • 建議(TextView) • LayOut- 介面設計, UI 決定, 操作方式決定 • 各種可用介面元件列表 • http://developer.android.com/guide/tutorials/views/index.html • Edit Text • http://developer.android.com/intl/zh-TW/reference/android/widget/EditText.html • Get/setText method • EditText Attributes • android:numeric • TextView • Button • 開始Coding

  18. Android 現況概述 進一步介紹開發環境 開發環境介紹與熟悉 Emulator Debug Tools 程式基本框架介紹 建立第一個App – BMI Plan & Design 開發演練 Pratice01- UILayOut Pratice02-完成程式邏輯 Pratice03-進行重構 Pratice04-Menu,Dialog 進階應用介紹 Pratice05-Activities & Intent Pratice06-Data Storage Pratice07-圖片與動畫

  19. 專案架構檢視

  20. 最初的程式碼

  21. LayOut • Editbox : 輸入身高 • Editbox: 輸入體重 • Button:開始計算 • TextView:顯示結果 • TextView:顯示建議

  22. 長這樣

  23. Android 現況概述 進一步介紹開發環境 開發環境介紹與熟悉 Emulator Debug Tools 程式基本框架介紹 建立第一個App – BMI Plan & Design 開發演練 Pratice01- UILayOut Pratice02-完成程式邏輯 Pratice03-進行重構 Pratice04-Menu,Dialog 進階應用介紹 Pratice05-Activities & Intent Pratice06-Data Storage Pratice07-圖片與動畫

  24. 範例(Project_Workshop) • Pratice_Study02 : 完成程式邏輯部分, • Pratice_Study03 : 進行重構, • Pratice_Study04 : 加入選單,並且透過選單,建立Dialog. • Pratice_Study05 :建立Activity , 並透過Intent呼叫,以及activity之間的資料傳遞 • Pratice_Study06 : 1. Preference 2. Daily widght Record ->SQLite • Pratice_Study07 : Frame Animation機制介紹

  25. 目標: • 功能: • 處理按下"確定"按鈕後,會發生的事-計算BMI,給予建議與結果 • 實際上要做的事: • 導入用到的模組、取得介面元件、對按鈕指定動作。

  26. 開發期間可以參考的文件 • 官方Reference文件 • http://developer.android.com/intl/zh-TW/reference/packages.html • 官方的開發基礎教學文件 • http://developer.android.com/intl/zh-TW/guide/index.html • 有哪些Views (LayOut 和UI)可以使用 • http://developer.android.com/intl/zh-TW/guide/tutorials/views/index.html • <AndroidSDK目錄>\docs\ 底下有相同的文件,不用上網查也可以 • EX: C:\Android\docs\

  27. 請開啟Project: Pratice_Study02 • Assist: HandOut_Day2.docx

  28. LayOut-將描述字串抽離到String.xml • "請輸入身高" 改到 Strings.xml 裡的 msg_Height • "170" 改到String.xml裡的 value_Height • .....

  29. LayOut-指定EditText只能輸入數字 • EditText->Property-> Numeric,選擇 Integer

  30. Code-入口

  31. Code- UI 類別的宣告 • 宣告一個Button Instance

  32. Code-與UI 資源檔的Binding • 存取UI 的識別符號 • 程式 • main.xml

  33. Button 事件處理的方式 - Listener

  34. 程式邏輯- 計算BMI 值的實作

  35. Result

  36. Pratice • 開啟Pratice_02 ,複習剛才上課所描述的,完成主程式邏輯部分, 可以參考HandOut 跟註解

  37. Android 現況概述 進一步介紹開發環境 開發環境介紹與熟悉 Emulator Debug Tools 程式基本框架介紹 建立第一個App – BMI Plan & Design 開發演練 Pratice01- UILayOut Pratice02-完成程式邏輯 Pratice03-進行重構 Pratice04-Menu,Dialog 進階應用介紹 Pratice05-Activities & Intent Pratice06-Data Storage Pratice07-圖片與動畫

  38. 這堂課的目標 • 1.重構-讓程式碼更容易維護 • 2.我們想把原本的訊息改成對話框型式 • 實作: 與使用者的對話 -> 對話框功能 • AlertDialog • MENU 按鈕的使用

  39. 重構-讓程式碼更容易閱讀 • findViews() • SetListener() • 重新命名變數 • 針對建議描述的部分->新增XML來描述字串

  40. 建立Alert Dialog • http://developer.android.com/intl/zh-TW/reference/android/app/Dialog.html • http://developer.android.com/intl/zh-TW/guide/topics/ui/dialogs.html

  41. 建立Alert Dialog

  42. 建立MENU清單,透過清單呼叫Dialog

  43. Result

  44. Pratice • 開啟Pratice_Study03 ,練習重構 • 開啟Pratice_Study04,建立Dialog跟Menu, 可以參考HandOut與註解

  45. Android 現況概述 進一步介紹開發環境 開發環境介紹與熟悉 Emulator Debug Tools 程式基本框架介紹 建立第一個App – BMI Plan & Design 開發演練 Pratice01- UILayOut Pratice02-完成程式邏輯 Pratice03-進行重構 Pratice04-Menu,Dialog 進階應用介紹 Pratice05-Activities & Intent Pratice06-Data Storage Pratice07-圖片與動畫

  46. 目標: • 改良顯示的方式 - 我們想將結果獨立顯示在新的頁面 • 將會使用到: • another Activity • Intent Reference : http://code.google.com/p/androidbmi/wiki/LifeCycle

More Related