Microsoft Word - 02.目錄.doc

Similar documents
多媒體應用 13 新增專案並完成版面配置 <ExMusic01> <activity_main.xml> ImageView ID imgplay ImageView ID imgstop ImageView ID imgfront TextView ID txtsong TextView ID t

主程式 : public class Main3Activity extends AppCompatActivity { ListView listview; // 先整理資料來源,listitem.xml 需要傳入三種資料 : 圖片 狗狗名字 狗狗生日 // 狗狗圖片 int[] pic =new

單步除錯 (1/10) 打開 Android Studio, 點選 Start a new Android Studio project 建立專案 Application name 輸入 BMI 點下 Next 2 P a g e

res/layout 目录下的 main.xml 源码 : <?xml version="1.0" encoding="utf 8"?> <TabHost android:layout_height="fill_parent" xml

Android Service

<4D F736F F D20342D312D302DB4FAC5E7C344A7DEAFE0B357BD64A4CEA4C0C3FEBD64A8D2C344A5D8>

用手機直接傳值不透過網頁連接, 來當作搖控器控制家電 ( 電視遙控器 ) 按下按鍵發送同時會回傳值來確定是否有送出 問題 :1. 應該是使用了太多 thread 導致在傳值上有問題 2. 一次按很多次按鈕沒辦法即時反應

PowerPoint 簡報

Android Android Android SDK iv

Dynamic Layout in Android

0511-Android程式之GPS應用_專題週記4

ShareText

Database_001

预览图 : (2) 在 SelectCity.java 中增加控件, 用于绑定 select_city 文件的 ListView, TextView,EditTest 等控件 代码和注释如下 :

Android Fragment

Lecture01_Android介绍

The Embedded computing platform

第一章 Android 基礎知識 -UI 設計及語法應用 驗證 Activity A. 解題要項 熟悉新增 Activity 的關鍵步驟以及在清單檔案內的註冊方式 熟悉 Activity 的切換方法與參數傳遞的技巧 熟悉 Activity 回傳結果 ( 含資料 ) 的關鍵步驟與接

Lecture01_Android介绍

RecyclerView and CardVew

投影片 1

書面

建立Android新專案

建立Android新專案

Microsoft PowerPoint - 07.Android 介面元件-TableLayout、Toast、AlertDialog

詞 彙 表 編 號 詞 彙 描 述 1 預 約 人 資 料 中 文 姓 名 英 文 姓 名 身 份 證 字 號 預 約 人 電 話 性 別 2 付 款 資 料 信 用 卡 別 信 用 卡 號 信 用 卡 有 效 日 期 3 住 房 條 件 入 住 日 期 退 房 日 期 人 數 房 間 數 量 入

Android 开发教程

實作SQLiteOpenHelper類別

1: public class MyOutputStream implements AutoCloseable { 3: public void close() throws IOException { 4: throw new IOException(); 5: } 6:

目 錄 一 ANDROID 開發系統需求 作業系統 開發工具... 1 二 安裝 ANDROID 開發工具 安裝 JDK 使用 APT-GET 安裝 使用套件管理程式安裝... 9 三 ANDROID 程式撰寫... 1

Microsoft Word - 第3章.doc

建模与图形思考

03 开发入门.key

任務二 : 產生 20 個有炸彈的磚塊, 放在隨機的位置編輯 Block 類別的程式碼 import greenfoot.; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) Write a description of class

Microsoft PowerPoint - 05.Android 介面元件-RelativeLayout、Button、TextVeiw、EditText

PowerPoint 簡報

Microsoft Word 範例試卷編號:GD docx

题目

投影片 1

Android 编程基础 Android 开发教程 & 笔记 1

Python a p p l e b e a r c Fruit Animal a p p l e b e a r c 2-2

電機工程系認可證照清單 /7/1

Microsoft PowerPoint - VB14.ppt

國人之健康行為初探

「西醫基層總額支付委員會《第28次委員會議紀錄

Android + NFC

团 学 要 闻 我 校 召 开 共 青 团 五 届 九 次 全 委 ( 扩 大 ) 会 议 3 月 17 日, 我 校 共 青 团 五 届 九 次 全 委 ( 扩 大 ) 会 议 在 行 政 办 公 楼 五 楼 会 议 室 举 行, 校 团 委 委 员 各 院 ( 系 ) 团 委 书 记 校 学 生


雲端 Cloud Computing 技術指南 運算 應用 平台與架構 10/04/15 11:55:46 INFO 10/04/15 11:55:53 INFO 10/04/15 11:55:56 INFO 10/04/15 11:56:05 INFO 10/04/15 11:56:07 INFO

Microsoft Word - 第4章 3D相册.doc

PowerPoint Presentation

840 提示 Excel - Excel -- Excel (=) Excel ch0.xlsx H5 =D5+E5+F5+G5 (=) = - Excel 00

Microsoft Word - 桂电教[2008]8号.doc

教育心理学教学案例分析

(Microsoft Word \256\325\260\310\267|\304\263\260O\277\375_\252k\250\356_.doc)

Microsoft Word - ACG chapter00c-3ed.docx

CC213

Chapter 1: Introduction

Java講義

Excel VBA Excel Visual Basic for Application

Java

輕鬆學 Dreamweaver CS5 網頁設計..\Example\Ch0\ \.html..\example\ch0\ \mouse.txt..\example\ch0\ \ _Ok.html 學習重點 JavaScript 複製程式碼 mouse.txt Ctrl+C Ctrl+C 0-4

内 容 简 介 本 书 是 一 本 关 于 语 言 程 序 设 计 的 教 材, 涵 盖 了 语 言 的 基 本 语 法 和 编 程 技 术, 其 中 包 含 了 作 者 对 语 言 多 年 开 发 经 验 的 总 结, 目 的 是 让 初 学 的 读 者 感 受 到 语 言 的 魅 力, 并 掌

Android + WebService

<4D F736F F D B0D3B77EC3FEA7DEC3C0C476C1C9A5BFA6A1B8D5C3442DB57BA6A1B35DAD702DBEC7ACEC2E646F6378>

RxJava

untitled

1

教育部補助資訊軟體人才培育先導計畫 100 年度課程發展專案計畫 實驗課程名稱 : IPC(Inter-Process Communication) 開發教師 : 張晉源老師 開發學生 : 林政揚 學校系所 : 樹德科技大學資訊工程學系


Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

AutoCAD 用戶如何使用 ArchiCAD

Microsoft Word - 第1章 Android基本概念.docx

Chapter 10

Microsoft Word - 第5章.doc

FETnet - Acer Iconia Tab  (A500 Wi-Fi 版) 平板電腦操作指南

Microsoft Word - Android 7.x.doc

使用手冊

Microsoft PowerPoint - VB5

Microsoft Word - ACI chapter00-1ed.docx

Transcription:

目錄 -1- 目錄 序 準備篇 一 使用說明... 0-2 二 標示說明... 0-6 三 注意事項... 0-7 第一類 Android 基礎知識 -UI 設計及語法應用 101. 整存整付計算機... 1-2 102. 電費計算機... 1-8 103. 點餐系統... 1-18 104. 計算 BMI 值... 1-23 105. MENU 功能選單... 1-36 106. 畫廊展示... 1-42 107. 驗證 Activity... 1-48 108. 選擇手機型號... 1-57 109. AlertDialog 顯示結果... 1-61 110. 動態密碼顯示... 1-69 第二類資料儲存應用 201. 猜數字遊戲... 2-2 202. 公尺與英呎轉換... 2-9 203. 匯率換算... 2-15 204. SQLite 與 MENU 作業... 2-22 205. 圖檔讀取... 2-34 206. 資料庫讀取... 2-40 207. 密碼鎖... 2-51 208. 我是誰?... 2-57

2-2 TQC+ 行動裝置應用程式設計認證指南解題秘笈 -Android 2 209. 姓名清單... 2-64 210. 簡單記事... 2-69 第三類基礎服務應用 301. 通訊錄搜尋... 3-2 302. 接收 SMS... 3-9 303. MP3 播放器... 3-17 304. 接收簡訊... 3-28 305. 接聽來電... 3-35 306. 查詢地圖... 3-40 307. 判斷發送簡訊狀態... 3-51 308. 判斷地標所屬區域... 3-60 309. 畫布程式... 3-69 310. 程式背景音樂... 3-76

Android 基礎知識 -UI 設計及語法應用 101. 整存整付計算機 102. 電費計算機 103. 點餐系統 104. 計算 BMI 值 105. MENU 功能選單 106. 畫廊展示 107. 驗證 Activity 108. 選擇手機型號 109. AlertDialog 顯示結果 110. 動態密碼顯示

1-2 TQC+ 行動裝置應用程式設計認證指南解題秘笈 -Android 2 101. 整存整付計算機 A. 解題要項 螢幕畫面 Layout 設計 strings.xml 檔字串設定 在 Java 檔裡, 取得使用者輸入資料, 經過運算處理後, 將結果顯示在螢幕上 B. 重點描述依照題目畫面的要求, 在 strings.xml 檔裡加入所要顯示的字串, 並給予每個字串 ID, 其指令格式如 :<string name="id"> 顯示的字串 </string> 此題目是以 LinearLayout 來設計, 螢幕畫面 LinearLayout 的特性是所加入的元件依序由上而下 ( 或由左至右 ) 排列 文字顯示使用 <TextView> 元件, 設定使用者輸入的欄位使用 <EditText> 元件, 按鈕使用 <Button> 元件 1 2 3 4 5 6 7 8 9 strings.xml <?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name"> 整存整付計算機 </string> <string name="title"> 整存整付試算 :</string> <string name="lend"> 本金 (NT$):</string> <string name="rate"> 年利率 (%):</string> <string name="number"> 存款期數 :</string> <string name="btn"> 計算本利和 </string> </resources> 程式說明行數說明 3~8 新增 string 並命名與宣告值 101. 整存整付計算機

第一類 Android 基礎知識 -UI 設計及語法應用 1-3 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 main.xml <?xml version="1.0" encoding="utf-8"?> <!-- 在考題程式碼中, 使用 LinearLayout, 並且 android:orientation 屬性設定為 "vertical", 所加入的元件依序由上而下排列 --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_height="fill_parent"> <!-- 加入一個 TextView 元件, 並設定顯示內容 --> <TextView android:text="@string/title" android:layout_height="wrap_content" /> <!-- 加入一個 TextView 元件, 並設定顯示內容 --> <TextView android:text="@string/lend" <!-- 加入一個 EditText 元件, 並設定輸入資料型態為 integer --> <EditText android:id="@+id/input_lend" android:layout_height="wrap_content" android:numeric="integer"/> <!-- 加入一個 TextView 元件, 並設定顯示內容 --> <TextView android:text="@string/rate" <!-- 加入一個 EditText 元件, 並設定輸入資料型態為 integer --> <EditText android:id="@+id/input_rate" android:layout_height="wrap_content" android:numeric="integer"/> <!-- 加入一個 TextView 元件, 並設定顯示內容 --> 101. 整存整付計算機

1-4 TQC+ 行動裝置應用程式設計認證指南解題秘笈 -Android 2 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 <TextView android:text="@string/number" <!-- 加入一個 EditText 元件, 並設定輸入資料型態為 integer --> <EditText android:id="@+id/input_number" android:layout_height="wrap_content" android:numeric="integer"/> <!-- 加入一個 Button 元件, 設定按鈕上的顯示文字, 按鈕的動作需要在 Java 程式中處理, 所以需要為此按鈕設定 ID --> <Button android:text="@string/btn" android:id="@+id/submit" <!-- 加入一個 TextView 元件, 此 TextView 元件的顯示內容需要在 Java 程式中處理, 所以需要為此元件設定 ID --> <TextView android:text="" android:id="@+id/amount" </LinearLayout> 程式說明 行數說明加入一個 TextView 元件, 字串的內容是從 ID 為 title 的 string 物 12~14 件取得,TextView 元件的寬度填滿一整層,TextView 元件的高度與所顯示的內容同高加入一個 TextView 元件, 字串的內容是從 ID 為 lend 的 string 17~19 物件取得,TextView 元件的寬度填滿一整層,TextView 元件的高度與所顯示的內容同高加入一個 EditText 元件, 設定此 EditText 元件的 ID(input_lend), EditText 元件的寬度填滿一整層,EditText 元件的高度與所顯示 22~25 的內容同高, 設定此欄位讓使用者輸入整數資料, 鍵盤會出現數字鍵盤加入一個 TextView 元件, 字串的內容是從 ID 為 rate 的 string 物 28~30 件取得,TextView 元件的寬度填滿一整層,TextView 元件的高 101. 整存整付計算機

第一類 Android 基礎知識 -UI 設計及語法應用 1-5 度與所顯示的內容同高 33~36 39~41 44~47 51~54 57~60 加入一個 EditText 元件, 設定此 EditText 元件的 ID(input_rate), EditText 元件的寬度填滿一整層,EditText 元件的高度與所顯示的內容同高, 設定此欄位讓使用者輸入整數資料, 鍵盤會出現數字鍵盤加入一個 TextView 元件, 字串的內容是從 ID 為 number 的 string 物件取得,TextView 元件的寬度填滿一整層,TextView 元件的高度與所顯示的內容同高加入一個 EditText 元件, 設定此 EditText 元件的 ID(input_number), EditText 元件的寬度填滿一整層,EditText 元件的高度與所顯示的內容同高, 設定此欄位讓使用者輸入整數資料, 鍵盤會出現數字鍵盤加入一個 Button 元件, 按鈕上顯示的文字從 ID 為 btn 的 string 物件取得, 設定此元件的 ID(submit),Button 元件的寬度填滿一整層,Button 元件的高度與所顯示的內容同高加入一個 TextView 元件, 字串的內容空白, 設定此元件的 ID(amount),TextView 元件的寬度填滿一整層,TextView 元件的高度與所顯示的內容同高 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 GDD01.java package COM.TQC.GDD01; import java.text.decimalformat; import android.app.activity; import android.os.bundle; /* 以下這些套件所含的類別會在程式中使用到, 所以必須 import 進來 在 Eclipse 中, 可以使用 ctrl+shift+o, 將程式中所用到的類別 import 進來, 程式設計師不用自行編寫 import 的指令 */ import android.view.view; import android.widget.button; import android.widget.edittext; import android.widget.textview; public class GDD01 extends Activity { /* Called when the activity is first created. */ 101. 整存整付計算機

1-6 TQC+ 行動裝置應用程式設計認證指南解題秘笈 -Android 2 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 @Override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); findviews(); // 將 main 檔裡的元件與 Java 檔裡的物件連結起來 setlisteners(); // 監聽 Button 按鈕被按, 執行相對應的動作 /* 先做物件宣告, 在 main.xml 檔裡, 有 1 個 <Button>,3 個 <EditText>, 還有 1 個有 ID 的 <TextView>*/ private Button button_calc; private EditText field_lend; private EditText field_rate; private EditText field_number; private TextView view_result; /* 透過 findviewbyid 建構子, 建立 main.xml 檔裡的元件與 Java 檔裡的物件連結關係 */ private void findviews(){ button_calc= (Button)findViewById(R.id.submit); field_lend=(edittext)findviewbyid(r.id.input_lend); field_rate=(edittext)findviewbyid(r.id.input_rate); field_number=(edittext)findviewbyid(r.id.input_number); view_result=(textview)findviewbyid(r.id.amount); /* 監聽 button_calc 這個按鈕物件是否被按, 如果被按, 執行 calcmoney 方法 */ private void setlisteners(){ button_calc.setonclicklistener(calcmoney); //calcmoney 方法的宣告及程式碼 private Button.OnClickListener calcmoney=new Button.OnClickListener(){ public void onclick(view v){ // 設定顯示數字的格式, 小數點後 0 位 DecimalFormat nf=new DecimalFormat("0"); // 取得 field_lend 物件裡的資料, 存放在 double 型態的變數 lend 裡 double lend=double.parsedouble(field_lend.gettext().tostring()); // 取得 field_rate 物件裡的資料, 存放在 double 型態的變數 rate 裡 101. 整存整付計算機

第一類 Android 基礎知識 -UI 設計及語法應用 1-7 57 58 59 60 61 62 63 64 65 66 double rate=double.parsedouble(field_rate.gettext().tostring()); // 取得 field_ number 物件裡的資料, 存放在 double 型態的變數 number 裡 double number =Double.parseDouble(field_number.getText().toString()); // 本利和 = 本金 *(1+ 年利率 /12/)%^ 存款期數 double total=lend*math.pow(1+rate/12/100, number); // 設定 view_result 物件的顯示字串 view_result.settext(" 本利和為 "+nf.format(total)); ; 程式說明 行 數說 明 11~14 程式中所需要使用到的類別 20~25 覆寫 oncreate 方法, 加入畫面顯示 選取畫面元件資料, 以及按鍵監聽 處理功能 先物件宣告, 在 main.xml 檔裡, 有 1 個 <Button>, 3 個 29~33 <EditText>, 還有 1 個有 ID 的 <TextView>, 以上這些元件的資料和動作, 都需要在 Java 檔裡處理, 所以 Java 檔裡需要有相對 應的元件 36~42 透過 findviewbyid 建構子, 建立 main.xml 檔裡的元件與 Java 檔裡的物件連結關係 45~47 監聽 button_calc 這個按鈕物件是否被按, 如果被按, 執行 calcmoney 方法 當 button_calc 按鈕被按下時, 執行以下所有的程式 從使用者 50~65 輸入的欄位裡, 將本金 利率 期數取出, 計算出本利和, 再將 結果顯示在 TextView 元件裡 101. 整存整付計算機