Chapter 4

Size: px
Start display at page:

Download "Chapter 4"

Transcription

1 Chapter 4 手機控制項應用

2 元件佈局

3 <LinearLayout> 線性佈局共有兩個方向 : 垂直 (vertical) 水帄 (horizontal) 決定垂直或是水帄的屬性為 Orientation android:orientation="vertical"

4 <LinearLayout> 線性佈局就是將在 < LinearLayout > 內的元件以線性的方式來呈現

5 <LinearLayout> - 範例 在這個範例中, 使用了 <TextView> 元件, 共使用了三個 <TextView>, 這三個元件都以垂直向下的方式來呈現

6 <LinearLayout> - 範例 布局文件 (res/layout/main.xml): <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:text=" 這是第一列 " android:textsize="22sp" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:text=" 這是第二列 " android:textsize="22sp" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:text=" 這是第三列 " android:textsize="22sp" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout>

7 <LinearLayout> - 常用屬性設定 android:orientation 在 <LinearLayout> 中, 此屬性代表元件的排列是垂直或水帄佈局 android:layout_width 代表此元件佈局的寬度, 若值為 fill_parent 則會填滿 parent 的寬度 ; 若值為 wrap_content 則元件寬度會依照內容大小而調整

8 <LinearLayout> - 常用屬性設定 android:layout_height 代表此元件佈局的高度, 若值為 fill_parent 則會填滿 parent 的高度 ; 若值為 wrap_content 則元件高度會依照內容大小而調整 android:layout_margin 指定這個 view 距離上下左右的額外距離

9 <LinearLayout> - 常用屬性設定 android: layout_marginbottom 指定這個 view 距離下方的額外距離 android: layout_marginleft 指定這個 view 距離左方的額外距離 android: layout_marginright 指定這個 view 距離右方的額外距離 android: layout_margintop 指定這個 view 距離上方的額外距離

10 <FrameLayout> FrameLayout 是所有佈局中最單純的 若同個 FrameLayout 中若有數個元件 以最上層的元件為主 若同個 FrameLayout 中有同大小的元件 只會看到最上層的元件 若同個 FrameLayout 中有不同大小的元件 會看到由下至上的元件

11 <FrameLayout> - 範例 This is 蓋過 That is

12 <FrameLayout> - 範例 布局文件 -1 (res/layout/main.xml) : <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <FrameLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1"> <!-- 最底層的元件 --> <EditText android:text="that is a framelayout example" android:id="@+id/text01" android:layout_width="wrap_content" android:layout_height="wrap_content" />

13 <FrameLayout> - 範例 布局文件 -2(res/layout/main.xml): <!-- 最上層的元件 --> <EditText android:text="this is" android:id="@+id/text02" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </FrameLayout> </LinearLayout> 下層元件為 "That is a framelayout example" 上層元件為 "Thit is"

14 <RelativeLayout>

15 <RelativeLayout> - 範例 用 RelativeLayout 展示如 LinearLayout 的結果

16 <RelativeLayout> - 範例 布局文件架構 (res/layout/main.xml): <!-- 顯示第一行的 TextView --> android:id="@+id/textview01" <!-- 顯示第二行的 TextView --> android:id="@+id/ TextView02" android:layout_below="@id/ TextView01" <!-- 顯示第三行的 TextView --> android:id="@+id/ TextView03" android:layout_below="@id/ TextView02" 程式以 TextView01 為參考,TextView02 置放在 TextView01 下方,TextView03 放置在 TextView02 下方

17 <RelativeLayout> - 範例 布局文件架構 (res/layout/main.xml): <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android=" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:text=" 這是第一列 " android:id="@+id/textview01" android:textsize="30sp" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:text=" 這是第二列 " android:id="@+id/textview02" android:textsize="30sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/textview01" /> <TextView android:text=" 這是第三列 " android:id="@+id/textview03" android:textsize="30sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/textview02" /> </RelativeLayout> 此範例用到三個 TextView, 利用三個 TextView 作 RelativeLayout

18 <RelativeLayout> - 常用屬性設定 android:layout_above 置於目標 id 元件的上方 android:layout_alignbaseline 置於與目標 id 元件同樣的基準線上 android:layout_alignbottom 讓自己的下邊界與目標 id 元件的下邊界在同一個位置

19 <RelativeLayout> - 常用屬性設定 android:layout_alignleft 讓自己的左邊界與目標 id 元件的左邊界在同一位置 android:layout_alignparentbottom 若為 true, 讓自己的下邊界與 Parent 的下邊界同位置 android:layout_alignparentleft 若為 true, 讓自己的左邊界與 Parent 的左邊界同位置

20 <RelativeLayout> - 常用屬性設定 android:layout_alignparentright 若為 true, 讓自己的右邊界與 Parent 的右邊界同位置 android:layout_alignparenttop 若為 true, 讓自己的上邊界與 Parent 的上邊界同位置 android:layout_alignright 讓自己的右邊界與目標 id 元件的右邊界在同一位置

21 <RelativeLayout> - 常用屬性設定 android:layout_aligntop 讓自己的上邊界與目標 id 元件的上邊界在同一個位置 android:layout_alignwithparentifmissing 若設為 true, 當參考的目標 id 不可用時, 會以 Parent 為參考目標 android:layout_below 置於目標 id 元件的下方

22 <RelativeLayout> - 常用屬性設定 android:layout_centerhorizontal 若為 true, 置於 Parent 水帄位置的中心 android:layout_centerinparent 若為 true, 置於 Parent 水帄以及垂直位置的中心 android:layout_centervertical 若為 true, 置於 Parent 垂直位置的中心 android:layout_toleftof/torightof 置於目標 id 元件的左方 / 右方

23 <TableLayout>

24 <TableLayout> - 範例 範例使用了三個 <TableRow>, 意即有三個 row

25 <TableLayout> - 範例 布局文件 -1(res/layout/main.xml): <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android=" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TableRow android:layout_margintop="20px"> <TextView android:layout_column="0" android:text=" 第一列 \n 第一行 " android:textsize="22sp" android:layout_marginleft="60px"/> <TextView android:layout_column="1" android:text=" 第一列 \n 第二行 " android:textsize="22sp" android:layout_marginleft="60px"/>/> </TableRow> <TableRow android:layout_margintop="20px"> <TextView

26 <TableLayout> - 範例 布局文件 -2(res/layout/main.xml): android:layout_column="0" android:text=" 第二列 \n 第一行 " android:textsize="22sp" android:layout_marginleft="60px"/> <TextView android:layout_column="1" android:text=" 第二列 \n 第二行 " android:textsize="22sp" android:layout_marginleft="60px"/>/> </TableRow> <TableRow android:layout_margintop="20px"> <TextView android:layout_column="0" android:text=" 第三列 \n 第一行 " android:textsize="22sp" android:layout_marginleft="60px"/> <TextView android:layout_column="1" android:text=" 第三列 \n 第二行 " android:textsize="22sp" android:layout_marginleft="60px"/>/> </TableRow> </TableLayout>

27 文字元件

28 TextView TextView 是個基本常用的元件 可使用 XML 來操作 可使用程式碼中的 Method 方法來操作 下列敘述 XML 與 Method 相對應之屬性功能 格式為 XML <-> Method

29 TextView 屬性功能介紹 android:autolink <-> setautolinkmask(int) 可讓文字上的連結自動變成可點擊的連結 android:gravity <-> setgravity(int) 設定文字在 View 中 x 軸和 y 軸相關數值 android:height <-> setheight(int) 設定 TextView 的高度 android:width <-> setwidth(int) 設定 TextView 的寬度

30 TextView 屬性功能介紹 android:hint <-> sethint(int) 當 Text 是空的時候, 就會顯示 hint 中的文字 android:lines <-> setlines(int) 設置 TextView 高度為幾個 Line 的高度, 值必須為整數型別 android:maxlength <-> setfilters(inputfilter) 設定 TextView 文字的最大長度

31 TextView 屬性功能介紹 android:password <-> settransformationmethod(transformation) 讓 Text 顯示成其他符號, 常用於輸入或顯示密碼時 android:text <-> settext(charsequence) 顯示的文字 android:textstyle <-> settypeface(typeface) 設定文字樣式

32 TextView 屬性功能介紹 android:textcolor <-> settextcolor(colorstatelist) 設定文字的顏色 android:textcolorlink <-> setlinktextcolor(int) 設定連結的顏色 android:textsize <-> settextsize(float) 設定文字大小

33 TextView 範例 若點擊上述的網址, 則會自動開啟瀏覽器跳至指定之網頁

34 TextView 範例一 純粹用 XML 語法產生連結 (res/layout/main.xml): <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:autolink="web" android:text="google - /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center" android:autolink="web" android:text="yahoo - /> </LinearLayout> 設置 autolink 為 web 設置 autolink 為 web

35 TextView 範例二 布局文件 (res/layout/main.xml): <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > </LinearLayout> 用程式碼產生連結 1(TextView.java): package ncu.bnlab; import android.app.activity; import android.os.bundle; import android.text.util.linkify; import android.view.gravity; import android.widget.linearlayout; import android.widget.textview;

36 TextView 範例二 用程式碼產生連結 2(TextView.java): public class TextViewExample extends Activity { /** Called when the activity is first created. public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); LinearLayout layout = (LinearLayout)findViewById(R.id.my_layout); TextView tv1 = new TextView(this); tv1.setgravity(gravity.center); tv1.setautolinkmask(linkify.web_urls); tv1.settext("google - layout.addview(tv1); TextView tv2 = new TextView(this); tv2.setgravity(gravity.center); tv2.setautolinkmask(linkify.web_urls); tv2.settext("yahoo - layout.addview(tv2);

37 TextView autolink 屬性 android:autolink <-> setautolinkmask(int) none autolink 預設值 all <-> Linkify.ALL 目前所有連結種類 <-> Linkify. _ADDRESSES 連結 phone <-> Linkify. PHONE_NUMBERS 電話號碼連結 web <-> Linkify.WEB_URLS 網址連結

38 AutoCompleteTextView AutoCompleteTextView 可達到簡易自動完成 Text 的功能 假設已有定義台灣的縣市英文名稱, 當輸入 Ta 時, 程式會自動將符合 Ta 的縣市名稱給列出來, 如範例所展示

39 AutoCompleteTextView 範例

40 AutoCompleteTextView 範例 布局文件 (res/layout/main.xml): <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <AutoCompleteTextView android:text="" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout>

41 AutoCompleteTextView 範例 程式碼 (TextView.java): package ncu.bnlab; import android.app.activity; import android.os.bundle; import android.widget.arrayadapter; import android.widget.autocompletetextview; public class AutoCompleteTextViewExample extends Activity { /** Called when the activity is first created. public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.r.layout.simple_dropdown_item_1line, TAIWAN); AutoCompleteTextView TaiwanCity = (AutoCompleteTextView)findViewById(R.id.city); TaiwanCity.setAdapter(adapter); private static final String[] TAIWAN = new String[] { "Keelung", "Taipei", "Taoyuan", "Hsinchu", "Miaoli", "Taichung", "Changhua", "Nantou", "Yunlin", "Chiayi", "Tainan", "Kaohsiung", "Pingtung ", "Yilan", "Hualien", "Taitung" ;

42 表單元件

43 Button Button 的 layout 方面會有兩種屬性 wrap_content layout_width 為 wrap_content 時, 這個 button 會依據 button 上的 text 長度為基準 fill_parent layout_width 為 fill_parent 時, 則會以 parent 最寬的長度為主

44 Button 範例 利用 XML 建立 Button 即可

45 ImageButton ImageButton 可以將圖片當作 button 的背景 利用此屬性 layout:src=" 圖片位置 " ImageButton 範例

46 ImageButton 範例 布局文件 (res/layout/main.xml): <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" /> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" /> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" /> </LinearLayout>

47 RadioButton RadioButton 為個別的一個按鈕 若要做成有多選一這種功能時, 則需將這些 RadioButton 放置一個 <RadioGroup> 中

48 RadioButton 範例

49 RadioButton 範例 布局文件 -1(res/layout/main.xml): <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:text=" 您對此次教學感到?" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <RadioGroup android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal >

50 RadioButton 範例 布局文件 -2(res/layout/main.xml): <RadioButton android:text=" 滿意 " android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="true"/> <RadioButton android:text=" 普通 " android:layout_width="wrap_content" android:layout_height="wrap_content" /> <RadioButton android:text=" 不滿意 " android:layout_width="wrap_content" android:layout_height="wrap_content" /> </RadioGroup> </LinearLayout>

51 ToggleButton ToggleButton 是一種類似開關的 Button 預設為 Off, 點擊後變為 On 開關上的文字也可以自訂 android:texton 和 android:textoff 當中的文字即為開關 On 或 Off 時顯示的文字

52 ToggleButton 範例 此範例中, 使用到一個簡單的事件處理, 當開關變動時在開關下方的 TextView 會跟著改變

53 ToggleButton 範例 布局文件 -1(res/layout/main.xml): <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:text="now is Off" android:layout_width="wrap_content" android:layout_height="wrap_content" />

54 ToggleButton 範例 布局文件 -2(res/layout/main.xml): <ToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margintop="30sp" android:texton=" 開 " android:textoff=" 關 "/> <TextView android:text="now is Off" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout>

55 ToggleButton 範例 程式碼 -1(ToggleButtonExample.java): public class ToggleButtonExample extends Activity { /** Called when the activity is first created. public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); final TextView textview01 = (TextView)findViewById(R.id.TextView01); final ToggleButton togglebutton01 = (ToggleButton) findviewbyid(r.id.togglebutton01); togglebutton01.setonclicklistener(new OnClickListener() { public void onclick(view v) { if (togglebutton01.ischecked()) { textview01.settext("now is ON"); else { textview01.settext("now is OFF"); );

56 ToggleButton 範例 程式碼 -2(ToggleButtonExample.java): final TextView textview02 = (TextView)findViewById(R.id.TextView02); final ToggleButton togglebutton02 = (ToggleButton) findviewbyid(r.id.togglebutton02); togglebutton02.setonclicklistener(new OnClickListener() { public void onclick(view v) { if (togglebutton02.ischecked()) { textview02.settext("now is ON"); else { textview02.settext("now is OFF"); ); 在 togglebutton01 以及 togglebutton02 設置 onclick 事件處理並利用 ischeck() 來判斷 togglebutton 的開關狀態, 再依照狀態改變 TextView01 和 TextView02 的文字內容

57 CheckBox CheckBox 只有兩種型態 checked unchecked CheckBox 可用在勾選多項選擇時

58 CheckBox 範例

59 CheckBox 範例 布局文件 -1(res/layout/main.xml): <TextView android:text=" 你喜歡的顏色? ( 可複選 )" android:id="@+id/textview01" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <LinearLayout android:orientation= horizontal android:layout_width="fill_parent" android:layout_height="wrap_content"> <CheckBox android:text=" 紅色 " android:id="@+id/checkbox01" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <CheckBox android:text=" 黃色 " android:id="@+id/checkbox02" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <CheckBox android:text=" 綠色 " android:id="@+id/checkbox02" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout>

60 CheckBox 範例 布局文件 -2(res/layout/main.xml): <TextView android:text=" 帄常的休閒活動? ( 可複選 )" android:id="@+id/textview02" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <CheckBox android:text=" 打球 " android:id="@+id/checkbox04" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <CheckBox android:text=" 游泳 " android:id="@+id/checkbox05" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <CheckBox android:text=" 上網 " android:id="@+id/checkbox06" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </LinearLayout> </LinearLayout>

61 DatePicker DatePicker 可讓使用者選擇年 月 日 當使用者按下 button 後,TextView 會顯示 DatePicker 所選的日期

62 DatePicker 布局文件 -1(res/layout/main.xml): <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <DatePicker android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_margintop="15sp"/> <Button android:text=" 確定 " android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_margintop="25sp"/> <TextView android:text="" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_margintop="35sp"/> </LinearLayout>

63 DatePicker 程式碼 (DatePickerExample.java): public class DatePickerExample extends Activity { /** Called when the activity is first created. public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); final DatePicker datepicker = (DatePicker) findviewbyid(r.id.datepicker01); final Button mybutton = (Button) findviewbyid(r.id.button01); final TextView textview = (TextView) findviewbyid(r.id.textview01); mybutton.setonclicklistener(new OnClickListener(){ public void onclick(view v) { int year = datepicker.getyear(); int month = datepicker.getmonth() + 1; int day = datepicker.getdayofmonth(); textview.settext( year + "-" + month + "-" + day ); );

64 TimePicker TimePicker 可讓使用者選擇時間 預設可讓使用者選擇 AM 或是 PM

65 TimePicker 範例 布局文件 (res/layout/main.xml): <TimePicker android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_margintop="15sp"/> <Button android:text=" 確定 " android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_margintop="25sp"/> <TextView android:text="" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_margintop="35sp" android:textsize="20sp"/>

66 TimePicker 範例 程式碼 (TimePickerExample.java): public class TimePickerExample extends Activity public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); final TimePicker timepicker = (TimePicker) findviewbyid(r.id.timepicker01); final Button mybutton = (Button) findviewbyid(r.id.button01); final TextView textview = (TextView) findviewbyid(r.id.textview01); mybutton.setonclicklistener(new OnClickListener(){ public void onclick(view v) { int hour = timepicker.getcurrenthour(); int minute = timepicker.getcurrentminute(); textview.settext( hour + " : " + minute ); );

67 EditText EditText 可讓使用者輸入文字 layout_width 為 wrap_content 時,EditText 的寬度會隨著輸入的字而變寬 當為 fill_parent 時則會固定為 parent 的寬度

68 EditText 範例

69 ProgressBar ProgressBar 可用於顯示程式執行進度 ProgressBar 有上述四種型態

70 ProgressBar 範例 布局文件 (res/layout/main.xml): <ProgressBar android:layout_height= wrap_content android:layout_width= 200px android:layout_gravity= center_horizontal android:layout_margintop= 20sp style=?android:attr/progressbarstylehorizontal /> <ProgressBar android:layout_height= wrap_content android:layout_width= wrap_content android:layout_gravity= center_horizontal android:layout_margintop= 20sp style=?android:attr/progressbarstylesmall /> <ProgressBar android:layout_height= wrap_content android:layout_width= wrap_content android:layout_gravity= center_horizontal android:layout_margintop= 20sp style=?android:attr/progressbarstyle /> <ProgressBar android:layout_height= wrap_content android:layout_width= wrap_content android:layout_gravity= center_horizontal android:layout_margintop= 20sp style="?android:attr/progressbarstylelarge" /> 改變 style 即可變更 ProgressBar 的樣式

71 RatingBar RatingBar 可用來製作評分系統 使用者可碰觸 RatingBar 的星星來達到評分 若碰觸星星的右半部則會加分 碰觸左半部則會扣分 最多為五顆星, 星星間隔為 0.5 顆星

72 RatingBar 範例

73 RatingBar 範例 布局文件 (res/layout/main.xml): <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <RatingBar android:layout_width="wrap_content" android:layout_height="wrap_content" android:numstars="3" /> <TextView android:text="" android:textsize="50sp" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <RatingBar android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:text="" android:textsize="50sp" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout>

74 RatingBar 範例 程式碼 (RatingBarExample.java): public class RatingBarExample extends Activity { /** Called when the activity is first created. public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); final TextView textview01 = (TextView) findviewbyid(r.id.textview01); final TextView textview02 = (TextView) findviewbyid(r.id.textview02); final RatingBar ratingbar01 = (RatingBar) findviewbyid(r.id.ratingbar01); ratingbar01.setonratingbarchangelistener(new OnRatingBarChangeListener(){ public void onratingchanged(ratingbar ratingbar, float rating, boolean fromuser) { textview01.settext(float.tostring(ratingbar01.getrating())); ); final RatingBar ratingbar02 = (RatingBar) findviewbyid(r.id.ratingbar02); ratingbar02.setonratingbarchangelistener(new OnRatingBarChangeListener(){ public void onratingchanged(ratingbar ratingbar, float rating,boolean fromuser) { textview02.settext(float.tostring(ratingbar02.getrating())); );

75 對話視窗元件

76 AlertDialog AlertDialog 為警告對話視窗, 像是離開程式或是刪除檔案時會跳出的對話視窗元件

77 AlertDialog 範例 程式碼 -1(AlertDialogExample.java): public class AlertDialogExample extends Activity public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); final Button button01 = (Button) findviewbyid(r.id.button01); final Button button02 = (Button) findviewbyid(r.id.button02); button01.setonclicklistener(new OnClickListener(){ public void onclick(view arg0) { About(); ); button02.setonclicklistener(new OnClickListener(){ public void onclick(view arg0) { Leave(); ); private void About() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.settitle(" 關於 ").setmessage(" 這是 Alert Dialog").show();

78 AlertDialog 範例 程式碼 -2(AlertDialogExample.java): private void Leave() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setmessage(" 確定要離開本程式嗎?").setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onclick(dialoginterface dialog, int which) { // TODO Auto-generated method stub AlertDialogExample.this.finish(); ).setnegativebutton("no", new DialogInterface.OnClickListener() { public void onclick(dialoginterface dialog, int which) { // TODO Auto-generated method stub dialog.cancel(); ); AlertDialog about_dialog = builder.create(); about_dialog.show();

79 AlertDialog.Builder - 屬性 create() 創建一個 AlertDialog setcancelable(boolean) 設為 false 時, 使用者無法使用其他方式關閉這個對話視窗, 只可使用對話視窗上給的操作方式來操作 seticon(drawable or int) 設置 Title 上的 Icon settitle(charsequence or int) 設定要顯示的 Title

80 AlertDialog.Builder - 屬性 setmessage(charsequence or int) 設定要顯示的內容 setpositivebutton(charsequence text, DialogInterface.OnClickListener listener) 設定正向 ( 左邊 ) 的按鈕 setnegativebutton(charsequence text, DialogInterface.OnClickListener listener) 設定反向 ( 右邊 ) 的按鈕 show() 顯示 AlertDialog

81 ProgressDialog ProgressDialog 可用於在等待其他程式或是在等待上傳時使用 ProgressDialog 有兩種形式 圓型 ProgressDialog 長條型 ProgressDialog

82 ProgressDialog 範例一 圓形的 ProgressDialog

83 ProgressDialog 範例一 程式碼 (AlertDialogExample01.java): public class ProgressDialogExample extends Activity { int nowprogressstatus = 0; Handler myhandler = new public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); final ProgressDialog dialog01 = ProgressDialog.show(this, "", " 程式正在開啟中...", false); Thread thread01 = new Thread(new Runnable() { public void run() { while (nowprogressstatus < 100) { try { Thread.sleep(500); catch (InterruptedException e) { // TODO Auto-generated catch block e.printstacktrace(); nowprogressstatus+=5; // While myhandler.post(new Runnable() { public void run() { dialog01.cancel(); ); ); thread01.start(); 圓形的 ProgressDialog

84 ProgressDialog 範例二 長條型 ProgressDialog

85 ProgressDialog 範例二 程式碼 (AlertDialogExample02.java): public class ProgressDialogExample02 extends Activity { int nowprogressstatus = 0; Handler myhandler = new public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); final ProgressDialog dialog02 = new ProgressDialog(this); dialog02.setprogressstyle(progressdialog.style_horizontal); dialog02.setmessage(" 讀取中..."); dialog02.show(); Thread thread02 = new Thread(new Runnable() { public void run() { while (nowprogressstatus < 100) { try { Thread.sleep(500); catch (InterruptedException e) { e.printstacktrace(); nowprogressstatus+=5; myhandler.post(new Runnable() { public void run() { dialog02.setprogress(nowprogressstatus); ); // While myhandler.post(new Runnable() { public void run() { dialog02.cancel(); ); ); thread02.start();

86 DatePickerDialog DatePickerDialog 除了選擇日期外, 在預設的對話視窗上會顯示目前挑選的日期以及星期幾的資訊

87 DatePickerDialog 範例 程式碼 (DatePickerDialogExample.java): public class DatePickerDialogExample extends Activity { /** Called when the activity is first created. public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); DatePickerDialog dpd = new DatePickerDialog(this,myOnDateSetListener,2009, 10, 05); dpd.show(); private DatePickerDialog.OnDateSetListener myondatesetlistener = new DatePickerDialog.OnDateSetListener() { public void ondateset(datepicker view, int year, int monthofyear, int dayofmonth) { // TODO Auto-generated method stub ;

88 DatePickerDialog 屬性 DatePickerDialog 有兩種建構種類 : public DatePickerDialog (Context context, DatePickerDialog.OnDateSetListener callback, int year, int monthofyear, int dayofmonth) public DatePickerDialog (Context context, int theme, DatePickerDialog.OnDateSetListener callback, int year, int monthofyear, int dayofmonth)

89 TimePickerDialog TimePickerDialog 選擇時間外, 預設在對話視窗會顯示所選的時間

90 TimePickerDialog 範例 程式碼 (TimePickerDialogExample.java): public class TimePickerDialogExample extends Activity { /** Called when the activity is first created. public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); TimePickerDialog tpd = new TimePickerDialog(this, mytimesetlistener, 12, 25, false); tpd.show(); private TimePickerDialog.OnTimeSetListener mytimesetlistener = new TimePickerDialog.OnTimeSetListener() { public void ontimeset(timepicker view, int hourofday, int minute) { // TODO Auto-generated method stub ;

91 TimePickerDialog 屬性 TimePickerDialog 有兩種建構種類 : public TimePickerDialog (Context context, TimePickerDialog.OnTimeSetListener callback, int hourofday, int minute, boolean is24hourview) public TimePickerDialog (Context context, int theme, TimePickerDialog.OnTimeSetListener callback, int hourofday, int minute, boolean is24hourview)

92 選單元件

93 Options Menu Options Menu 就是透過按手機或模擬器上的 menu 鍵顯示的功能表 最多可以顯示六項, 稱為 Icon Menu 超過六項就會以 More 的功能項來表示其餘的選項, 稱為 Expanded Menu

94 Options Menu 範例一 此種型式的 Menu 就稱為 OptionsMenu

95 Options Menu 範例一 程式碼 -1(OptionsMenuEX.java): public class OptionsMenu extends Activity { public static final int aboutbtnid = Menu.FIRST; public static final int exitbtnid = Menu.FIRST + 1; /** Called when the activity is first created. public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); public boolean oncreateoptionsmenu(menu menu) { menu.add(0, aboutbtnid, 0, "About"); menu.add(0, exitbtnid, 0, "Exit"); return true;

96 Options Menu 範例一 程式碼 -2(OptionsMenuEX.java): public boolean onoptionsitemselected(menuitem item) { super.onoptionsitemselected(item); switch( item.getitemid() ) { case aboutbtnid: opendialog(); break; case exitbtnid: finish(); break; return true; public void opendialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setmessage("about OptionsMenu"); builder.settitle("about"); builder.setpositivebutton("ok", new DialogInterface.OnClickListener() public void onclick(dialoginterface dialog, int which) { ).show();

97 Options Menu 範例二

98 Options Menu 範例二 程式碼 -1(OptionsMenuEX.java): public class OptionsMenu2 extends Activity { public static final int aboutbtnid = Menu.FIRST; public static final int exitbtnid = Menu.FIRST + 1; public static final int searchbtnid = Menu.FIRST + 2; public static final int addbtnid = Menu.FIRST + 3; public static final int playbtnid= Menu.FIRST + 4; public static final int delbtnid = Menu.FIRST + 5; public static final int openbtnid = Menu.FIRST + 6; /** Called when the activity is first created. public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); public boolean oncreateoptionsmenu(menu menu) { menu.add(0, aboutbtnid, 0, "About"); menu.add(0, exitbtnid, 0, "Exit"); menu.add(0, searchbtnid, 0, "Search"); menu.add(0, addbtnid, 0, "Add"); menu.add(0, playbtnid, 0, "Play"); menu.add(0, delbtnid, 0, "Delete"); menu.add(0, openbtnid, 0, "Open"); return true;

99 Options Menu 範例二 程式碼 -2(OptionsMenuEX2.java): public boolean onoptionsitemselected(menuitem item) { super.onoptionsitemselected(item); switch( item.getitemid() ) { case aboutbtnid: opendialog(); break; case exitbtnid: finish(); break; return true; public void opendialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setmessage("about OptionsMenu"); builder.settitle("about"); builder.setpositivebutton( OK, new DialogInterface.OnClickListener() public void onclick(dialoginterface dialog, int which) { ).show();

100 Options Menu 範例三 在功能表中增加圖示

101 Options Menu 範例三 程式碼 (OptionsMenuEX.java): public boolean oncreateoptionsmenu(menu menu) { menu.add(0, aboutbtnid, 0, "About").setIcon(R.drawable.icon); menu.add(0, exitbtnid, 0, "Exit").setIcon(R.drawable.icon); return true; 透過 seticon() 方法在功能表中增加圖示

102 Context Menu Android 中的 Context Menu 與一般個人電腦中的滑鼠右鍵非常類似 當在 View 上, 使用者長按螢幕不放兩秒, 將會出現一個浮動功能表 Context Menu 不支援圖示或快捷鍵

103 Context Menu 範例

104 Context Menu 範例 程式碼 (ContextMenuEX.java): public class ContextMenu extends Activity { public String checkeditem = ""; public static final int newbtnid = Menu.FIRST; public static final int openbtnid = Menu.FIRST + 1; public static final int closebtnid = Menu.FIRST + public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); Button filebtn = (Button)findViewById(R.id.fileBtn); Button editbtn = (Button)findViewById(R.id.editBtn); registerforcontextmenu(filebtn); registerforcontextmenu(editbtn); public void oncreatecontextmenu(android.view.contextmenu conmenu, View v, ContextMenuInfo menuinfo) { super.oncreatecontextmenu(conmenu, v, menuinfo); conmenu.setheadertitle("context Menu"); conmenu.add(0, newbtnid, 0, "New").setNumericShortcut('1'); conmenu.add(0, openbtnid, 0, "Open").setCheckable(true); conmenu.add(0, closebtnid, 0, "Close").setIcon(R.drawable.icon); public boolean oncontextitemselected(menuitem item) { super.oncontextitemselected(item); return false;

105 Sub Menu 一個子功能表可以被加入任何功能表中, 但不能加入另外的子功能表中 當應用程式有很多功能可以被分類時, 會非常好用, 就像是一般電腦的功能表

106 Sub Menu 範例

107 Sub Menu 範例 程式碼 -1(SubMenuEX.java): public class SubMenus extends Activity { public String checkeditem = ""; public static final int newbtnid = Menu.FIRST; public static final int openbtnid = Menu.FIRST + 1; public static final int closebtnid = Menu.FIRST + public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); Button filebtn = (Button)findViewById(R.id.fileBtn); Button editbtn = (Button)findViewById(R.id.editBtn); registerforcontextmenu(filebtn); registerforcontextmenu(editbtn);

108 Sub Menu 範例 程式碼 -2(SubMenuEX.java): public void oncreatecontextmenu(android.view.contextmenu conmenu, View v, ContextMenuInfo menuinfo) { super.oncreatecontextmenu(conmenu, v, menuinfo); /* conmenu.setheadertitle("context Menu"); conmenu.add(0, newbtnid, 0, "New").setNumericShortcut('1'); // 利用數字選擇 conmenu.add(0, openbtnid, 0, "Open").setCheckable(true); // 設定 checkbox conmenu.add(0, closebtnid, 0, "Close").setIcon(R.drawable.icon); //ContextMenu 不支援 icon*/ SubMenu sub = conmenu.addsubmenu("submenu"); sub.add("add..."); sub.add("delete..."); public boolean oncontextitemselected(menuitem item) { super.oncontextitemselected(item); return false;

109 Spinner Spinner 是一個 widget, 允許使用者從一群選項中選出其中一個 Spinner 就類似下拉式選單, 當列表超過螢幕大小時也可允許捲動

110 Spinner 範例

111 Spinner 範例 布局文件 -1(res/layout/main.xml): <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:padding="10dip" android:layout_width="fill_parent" android:layout_height="wrap_content"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margintop="10dip" android:text="please select a planet:" /> <Spinner android:id="@+id/spinner" android:layout_width="fill_parent" android:layout_height="wrap_content" android:drawselectorontop="true" android:prompt="@string/planet_prompt" /> </LinearLayout> 首先我們將 main.xml 改寫成下列範例中的程式碼

112 Spinner 範例 布局文件 (res/value/strings.xml): <string name="planet_prompt">choose a item</string> 布局文件 (res/value/arrays.xml): 其中我們新增了 Spinner 的標籤, 接著新增這段程式碼至 strings.xml 中 <?xml version="1.0" encoding="utf-8"?> <resources> <string-array name= cards"> <item>visa</item> <item>mastercard</item> <item>jbc</item> <item>hsbc</item> <item>citibank</item> <item>sd</item> </string-array> </resources> 接著在 res/value/ 中建立一下名為 arrays.xml 的文件,arrays.xml 程式碼如下

113 Spinner 範例 程式碼 -1(SpinnerEX.java): package ncu.bnlab.spinnerexample; import android.app.activity; import android.os.bundle; import android.widget.arrayadapter; import android.widget.spinner; public class SpinnerEX extends Activity { /** Called when the activity is first public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); 最後將 Spinner 的 JAVA 原始檔開啟, 在 oncreate() 中加入程式碼 Spinner s = (Spinner)findViewById(R.id.spinner);

114 Spinner 範例 程式碼 -2(SpinnerEX.java): /* 設定功能表項目陣列, 使用 createfromresource 方法 */ ArrayAdapter adapter = ArrayAdapter.createFromResource( this, R.array.cards, android.r.layout.simple_spinner_item); /* 設定選單 */ adapter.setdropdownviewresource(android.r.layout.simple_spinner_dropdown_item); /* 設定 Adapter */ s.setadapter(adapter);

115 Notifying 元件

116 Toast Notification 消息條通知是一個在視窗彈出的訊息, 它只顯示內容所需的空間且使用者當前活動仍然保持可見和可互動 這個通知自動淡入淡出, 且不接受互動事件, 因為消息條可以從一個後台服務 Service 中建立, 即便應用程式不可見, 它也將呈現出來

117 Toast Notification 一個消息條是用來顯示簡短文字訊息的好方法, 例如說 檔案已儲存, 當使用者正在注意螢幕時, 這種方式就可以提醒使用者動作已完成 一個消息條不能接受使用者互動事件 ; 如果希望使用者回答並採取對應動作, 可以考慮使用一個狀態條通知 Status Bar Notification, 在下一小節將會介紹

118 Toast Notification 首先,Toast 物件有一個 maketext 的方法, 這個方法帶有三個參數 : 應用程式內容 文字訊息 顯示時間長短 接著它會回傳一個初始化的 Toast 物件, 在程式中可以使用 show() 方法來顯示

119 Toast Notification 一般標準的 Toast 預設位置是靠底下偏中間, 可以透過 setgravity(int, int, int) 方法改變, 在下面的範例中程式設定讓 Toast 物件靠左上角顯示 如果要讓 Toast 物件往右移動, 增加第二個參數 (x-postion) 的數值 如果要讓 Toast 物件往下移動, 增加第三個參數 (y-postion) 的數值

120 Toast Notification 範例

121 Toast Notification 範例 程式碼 (ToastNotificationEX.java): public class ToastNotification extends Activity { /** Called when the activity is first created. public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); /* 第一種 maketext 用法 */ Context context1 = getapplicationcontext(); CharSequence text1 = "Short Toast"; int duration1 = Toast.LENGTH_SHORT; // 設定停留長短 Toast toast = Toast.makeText(context1, text1, duration1); toast.setgravity(gravity.top Gravity.LEFT, 0, 0); // 設定 Toast 物件位置 toast.show(); /* 第二種 maketext 用法 */ Context context2 = getapplicationcontext(); CharSequence text2 = "Long Toast"; int duration2 = Toast.LENGTH_LONG; // 設定停留長短 Toast.makeText(context2, text2, duration2).show();

122 Status Bar Notification 一個狀態條通知會增加一個圖示到 系統狀態列上 一個可選的滾動訊息 在這個 通知 視窗中的一個擴展消息 當使用者選擇這個擴展消息時,Android 發出這個通知所定義的一個 Intent( 通常是啟動一個活動 ) 也可配置這個通知使用聲音 震動和設備上的閃燈來警告用戶

123 Status Bar Notification 當應用程式是以後台服務運行且需要通知使用者事件時, 這類通知是一種理想的方式 如果需要在活動仍處於焦點下時警告使用者一個發生的事件, 可以使用對話框通知 Dialog Notification

124 Status Bar Notification 一個活動或服務可以起始一個狀態條通知, 然而活動只有在啟動狀態及處於焦點狀態時才可以完成這個動作 所以當使用者在使用其他應用程式或設備處於休眠狀態時, 服務可以在背景中建立狀態條通知

125 Status Bar Notification 一個活動或服務可以起始一個狀態條通知, 然而活動只有在啟動狀態及處於焦點狀態時才可以完成這個動作 所以當使用者在使用其他應用程式或設備處於休眠狀態時, 服務可以在背景中建立狀態條通知

126 Status Bar Notification 範例

127 Status Bar Notification 範例 程式碼 (StatusBarNotificationEX.java): public class StatusBarNotification extends Activity { /** Called when the activity is first created. public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); String ns = Context.NOTIFICATION_SERVICE; NotificationManager mnotificationmanager = (NotificationManager) getsystemservice(ns); int icon = R.drawable.icon; // 通知圖示 CharSequence tickertext = "Hello!!!"; // ticker-text long when = System.currentTimeMillis(); // 通知時間 Context context = getapplicationcontext(); // 應用程式內容 CharSequence contenttitle = " 這是訊息標題 "; // 訊息標題 CharSequence contenttext = " 這是訊息內文 "; // 訊息內文 Intent notificationintent = new Intent(this, StatusBarNotification.class); PendingIntent contentintent = PendingIntent.getActivity(this, 0, notificationintent, 0); Notification notification = new Notification(icon, tickertext, when); notification.setlatesteventinfo(context, contenttitle, contenttext, contentintent); final int HELLO_ID = 1; mnotificationmanager.notify(hello_id, notification); // 傳送通知

128 Dialog Notification 一個對話框通知一般是出現在當前活動前面的一個視窗 背後的活動遺失焦點而由此對話框接受所有的使用者互動 對話框通常用於和運行中應用程式直接相關的通知和短暫活動

129 Dialog Notification 應該使用對話框來顯示一個進度條或者一個需要使用者確認的訊息 例如說帶有 確認 和 取消 按鈕的警告 也可將對話框作為構成應用程式界面整體的元件以及用於除了通知之外的其它目的

130 顯示元件

131 ImageView 用於顯示一個圖樣, 例如說一個圖示或圖片 ImageView 類別可以載入來自不同來源的圖片 ( 可能來自資源或內容提供商 ), 它可以用於任何佈局管理器, 並提供多種顯示選項, 例如 : 縮放 著色

132 ImageView - 屬性功能介紹 android:adjustviewbounds <-> setadjustviewbounds(boolean) 如果要讓 ImageView 根據 drawable 資源大小去調整邊界, 必須將此值設為 true android:croptopadding 如果為真, 此圖片將被裁剪成適合的大小 android:maxheight <-> setmaxheight(int) 設定最大高度

133 ImageView - 屬性功能介紹 android:maxwidth <-> setmaxwidth(int) 設定最大寬度 android:scaletype <-> setscaletype(imageview.scaletype) 控制圖片如何縮放或移動且配合 ImageView 的大小 android:src <-> setimageresource(int) 為此 ImageView 內容設定資源圖檔 android:tint <-> setcolorfilter(int,porterduff.mode) 設定著色的過濾器

134 ImageView 範例

135 ImageView 範例 程式碼 -1(ImageViewEX.java): public class ImageViewEX extends Activity public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); ImageView imageview = new ImageView(this); imageview.setimageresource(r.drawable.christmas); setcontentview(imageview); 將 drawable 中的圖檔資源置入 imageview 的圖片來源

136 ListView Android 除了提供 CheckBox 與 RadioButton 的物件之外, 還提供另一種更為方便且表現多樣化的物件 ListView

137 ListView 範例

138 ListView 範例一程式碼 程式碼 -1(ListViewEX.java): public class ListViewEX extends Activity public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); String[] Data = {" 網路概論 "," 通訊網路實驗 "," 通訊概論 "; ListView listview = new ListView(this); // 設定 ListView 選擇的方式 : // 單選 :ListView.CHOICE_MODE_SINGLE // 多選 :ListView.CHOICE_MODE_MULTIPLE listview.setchoicemode( ListView.CHOICE_MODE_SINGLE ); ArrayAdapter varraydata = new ArrayAdapter( this, android.r.layout.simple_list_item_single_choice, Data ); // 設定 ListView 的接收器, 做為選項的來源 listview.setadapter( varraydata ); // ListView 設定為 ContentView setcontentview(listview);

139 ListView 範例二程式碼 程式碼 -2(ListViewEX.java): public class ListViewEX2 extends ListActivity public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); String[] Data = { " 葷食 "," 素食 "," 兩者皆可 " ; ListView listview = this.getlistview(); listview.setchoicemode( ListView.CHOICE_MODE_SINGLE ); // ListView 的選項來源由陣列提供 this.setlistadapter( new ArrayAdapter( this, android.r.layout.simple_list_item_single_choice, Data ));

140 GridView GridView 可以顯示一個二維滾動格框, 也可搭配其他元件, 呈現類似一般手機上的功能表

141 GridView 範例

142 GridView 範例 GridView 程式碼 -1(GridViewEX.java): public class GridViewEX extends Activity public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); GridView gridview = (GridView) findviewbyid(r.id.gridview); gridview.setadapter(new ImageAdapter(this));

143 GridView 範例 ImageAdapter 程式碼 -1(ImageAdapter.java): public class ImageAdapter extends BaseAdapter { private Context mcontext; public ImageAdapter(Context c) { mcontext = c; public int getcount() { return mthumbids.length; public Object getitem(int position) { return null; public long getitemid(int position) { return 0;

144 GridView 範例 ImageAdapter 程式碼 -2(ImageAdapter.java): public View getview(int position, View convertview, ViewGroup parent) { ImageView imageview; if (convertview == null) { imageview = new ImageView(mContext); imageview.setlayoutparams(new GridView.LayoutParams(85, 85)); imageview.setscaletype(imageview.scaletype.center_crop); imageview.setpadding(8, 8, 8, 8); else { imageview = (ImageView) convertview; imageview.setimageresource(mthumbids[position]); return imageview; private Integer[] mthumbids = { R.drawable.icon, R.drawable.christmas, R.drawable.favorite, R.drawable.ipod ;

145 SurfaceView 依照傳統的作法, 要快速更新畫面, 如果做遊戲之類的應用 通常會新增執行緒處理工作後, 使用 handler 傳送訊息給 View 顯示畫面 或在非使用者執行緒呼叫 View 做法就是透過 SurfaceView 的 getholder() 取得 SurfaceHolder, 然後對 SurfaceHolder 的 Canvas 畫圖

146 SurfaceView 範例

147 SurfaceView 範例 程式碼 -1(SurfaceViewEX.java): public class SurfaceViewEX extends Activity { public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(new MyView(this)); // 內部類別 class MyView extends SurfaceView implements SurfaceHolder.Callback { SurfaceHolder holder; public MyView(Context context) { super(context); holder = this.getholder();// 獲取 Holder public void surfacechanged(surfaceholder holder, int format, int width, int height) {

148 SurfaceView 範例 程式碼 public void surfacecreated(surfaceholder holder) { new Thread(new public void surfacedestroyed(surfaceholder holder) { // 執行緒 class MyThread implements Runnable public void run() { Canvas canvas = holder.lockcanvas(null);// 獲得畫布 Paint mpaint = new Paint(); mpaint.setcolor(color.blue); canvas.drawrect(new RectF(40,60,80,80), mpaint); holder.unlockcanvasandpost(canvas);// 解鎖畫布並更新顯示

149 WebView Webview 是用於顯示 web 頁面的視景 在活動中的任何一個瀏覽器或簡易地顯示一些線上內容 它使用 Webkit 繪圖引擎去顯示頁面且包含 上一頁 下一頁 放大縮小 文字搜尋 等等方法

150 WebView 範例

151 WebView 範例 <uses-permission android:name="android.permission.internet" /> 布局文件 (res/layout/main.xml): 為了使活動可以在 WebView 存取 Internet 及讀取 web 頁面, 需在 AndroidManifest.xml 中加入 INTERNET 權限 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <WebView android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout> 修改 main.xml 中的布局方式

152 WebView 範例 程式碼 (WebViewEX.java): public class WebViewEX extends Activity { /** Called when the activity is first created. public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); WebView webview; webview = (WebView) findviewbyid(r.id.webview); webview.getsettings().setjavascriptenabled(true); webview.loadurl(" 此處以 Google 網站作為連接範例

153 MapView 可在活動中顯示 Google Map 地圖畫面, 並可於地圖上進行標示動作, 與一般在瀏覽器上操作類似 在此範例中需使用到 Google Map API 金鑰, 此部分將於後面章節作詳細介紹

154 MapView 範例

155 MapView 範例 <uses-library android:name="com.google.android.maps" /> 首先必須在 AndroidManifest.xml 中的 <application> 標籤內加入 Google Map API <uses-permission android:name="android.permission.internet" /> 接著在 AndroidManifest.xml 中的 <manifest> 標籤內加入存取網路的權限

156 MapView 範例 布局文件 (res/layout/main.xml): <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <view class = "com.google.android.maps.mapview" android:id="@+id/mapview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:clickable="true" android:apikey= 你的 apikey" /> </LinearLayout> 其中 android:apikey 需要去 Google 網站申請

157 MapView 範例 程式碼 (MapViewEX.java): public class MapViewEX extends MapActivity { /** Called when the activity is first created. protected boolean isroutedisplayed() { return false; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); MapView mv = (MapView) findviewbyid(r.id.mapview); MapController controller = (MapController)mv.getController(); GeoPoint p = new GeoPoint((int) (25 * ),(int)(121.5 * )); controller.animateto(p); controller.setzoom(15);

158 客製化元件

159 客製化元件 介紹完 Android 所提供的各類元件後, 其實 Android 本身也可以自行製作客製化元件來用, 像是 Button TextView EditText ListView CheckBox RadioButton 與一些其他有特殊用途的 AutoCompleteTextView ImageSwitcher 和 TextSwitcher 等等搭配 Layout 組成新元件

160 客製化元件 如果只是需要改變某個元件的小部分, 那就可以直接覆寫元件中的方法即可 完全客製化元件的方法可以建立一些用於顯示的圖形元件, 也許一個像電壓的圖形計量器, 或者是卡拉 OK 中的波紋隨著音樂滾動

161 客製化元件 在 Android 中, 可以用自訂的要求輕鬆地建立客製化元件, 下面將簡單介紹如何創造客製化元件 : 最為通用的毫無疑問是 View 類別, 因此, 最開始要建立一個基於此類別的一個子類別 寫一個函數從 XML 文件中取得屬性和參數, 當然也可以自行定義這些屬性和參數 可能有必要撰寫本身的事件監聽器 修改函數和一些元件本身功能上的程式碼 如果希望元件能夠顯示什麼東西, 可能會重載 onmeasure() 函數 當兩個函數都用預設的, 那 ondraw() 函數將不會做任何事情, 並且預設的 onmeasure() 函數會自動的設定一個 100x100 的尺寸, 這個尺寸可能非我們所要的 其他有必要重載的 on... 開頭系列函數都需要重新撰寫一次

162 客製化元件 ondraw() 函數將會傳送一個 Canvas 對象, 透過它即可在 2D 圖形上做任何事情, 包含其他的一些標準和通用的元件 格式化本文, 任何可以想到的東西都可以透過它呈現 但此不包含 3D 圖形, 如果想使用 3D 圖形, 應該把父類別由 View 改為 SurfaceView 類, 並使用獨立的執行緒

163 客製化元件 onmeasure() 函數較為複雜一些, 因為這個函數是呈現元件和容器互動的關鍵部分, onmeasure() 應該重載, 讓它能夠有效且準確的表現它所包含部分的測量值 一旦測量寬度和高度出來後, 就要立即呼叫 setmeasureddimension() 方法

164 客製化元件 整體來說, 執行 onmeasure() 函數分為以下幾個步驟 : 重載的 onmeasure() 方法會被呼叫, 高度和寬度參數同時也會牽涉到 (widthmeasurespec 和 heighmeasurespec 兩個參數都是整數類型 ), 同時還要考慮產品螢幕的尺寸限制 元件要透過 onmeasure() 計算得到必要的測量長度和寬度, 用來顯示元件 另外它可以實現一些規格以外的功能, 像是滑動 捲動 裁切 等等 一旦高度和寬度計算出來之後, 必須呼叫 setmeasureddimension(int width, int height), 否則就會導致系統異常

165 課後習題 1. 在 <LinearLayout> 中有兩種方向, 請問要更改 Layout 方向的屬性為何? 2. 請問 <RelativeLayout> 的佈局概念為何? 詴舉例說明 3. 詴說明 <TableLayout> 和 <TableRow> 之間的關係 4. 如何讓 <TextView> 中的文字有自動連結的功能? 5. 如何讓某個 RadioButton 為預設勾選項目? 6. ProgressBar 有幾種樣式? 若要更改樣式要如何修改?

166 課後習題 7. Options Menu 最多可顯示幾個項目, 若超過上限會如何? 8. ContextMenu 是否可支援圖示或快捷鍵? 9. Toast 可否更改顯示時間之間隔? 需如何修改? 10. StatusBarNotification 如欲通知使用者需在程式中呼叫哪個方法? 11. ListView 如何設定單選或多選? 12. 若要實現手機上之程式選單, 可使用本章中何種元件? 13. 如需在手機上使用 MapView, 需在 AndroidManifest.xml 加入哪項指令?

Android 基礎教學

Android 基礎教學 Android 基礎教學 吳柏翰 1 Outline Android 歷史起源 Android 優勢與市場未來趨勢 安裝 Android SDK 建立專案 模擬器的執行與操作 使用 Log 及 IDE 除錯工具 實機運作 2 Android 歷史起源 起源 隨著手機與網際網路結合, 上網普及化之後, 使用者對手機的功能有截然不同的需求 透過網際網路, 各種新的服務與應用應運而生, 使用者也希望手機平台能像電腦一樣,

More information

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

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

More information

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

res/layout 目录下的 main.xml 源码 : <?xml version=1.0 encoding=utf 8?> <TabHost android:layout_height=fill_parent xml 拓展训练 1- 界面布局 1. 界面布局的重要性做应用程序, 界面是最基本的 Andorid 的界面, 需要写在 res/layout 的 xml 里面, 一般情况下一个 xml 对应一个界面 Android 界面布局有点像写 html( 连注释代码的方式都一样 ), 要先给 Android 定框架, 然后再在框架里面放控件,Android 提供了几种框架,AbsoluteLayout,LinearLayout,

More information

Microsoft PowerPoint - 08_Android_Spring11_Control2.pptx

Microsoft PowerPoint - 08_Android_Spring11_Control2.pptx 作者 : 李昭賢作者 : 洪振偉編撰整理者 : 陳彥霖 學習目標 1. 透過 XML 產生控制項 2. 透過 Java 產生控制項 3. 新增事件 (Event) 處理 AnalogClock / DigitalClock 負責顯示時間 AnalogClock: 以傳統鐘錶指針方式顯示時與分 DigitalClock: 以數位數字方式顯示時 分與秒 類比小時鐘 (AnalogClock 類別 ) 數位小時鐘

More information

Dynamic Layout in Android

Dynamic Layout in Android Dynamic Layout in Android 建國科技大學資管系 饒瑞佶 2013/5 V1 Layout 多半都透過 res/layout/xml 格式設定來達成 Android 是 OOP, 所以可以動態產生 Layout 重點是 Layout 的階層關係 (Hierarchy) 需要處理對應事件 最後一樣用 setcontentview 加入 Layout 一 加入現有 Layout 中

More information

Android Service

Android Service Android Service- 播放音樂 建國科技大學資管系 饒瑞佶 2013/7 V1 Android Service Service 是跟 Activity 並行 一個音樂播放程式若沒使用 Service, 即使按 home 鍵畫面離開之後, 音樂還是照播 如果再執行一次程式, 新撥放的音樂會跟先前撥放的一起撥, 最後程式就會出錯 執行中的程式完全看不到! 但是, 寫成 Service 就不同了

More information

Android Fragment

Android Fragment Android Fragment 建國科技大學資管系饒瑞佶 2017/10 V1 Android 3.0 後才支援 Fragment 解決部分 App 適應螢幕大小的問題 它類似於 Activity, 可以像 Activity 可以擁有自己的版面設計, 也和 Activity 一樣有自己的生命週期 ( 具備 oncreate() oncreateview() 與 onpause() 方法 ) LifeCycle

More information

The Embedded computing platform

The Embedded computing platform Android User Interfaces Hsiao-Lung Chan, Ph.D. Dept Electrical Engineering Chang Gung University, Taiwan chanhl@maili.cgu.edu.tw Basic control components Text components TextView EditText Button compoents

More information

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

單步除錯 (1/10) 打開 Android Studio, 點選 Start a new Android Studio project 建立專案 Application name 輸入 BMI 點下 Next 2 P a g e Android Studio Debugging 本篇教學除了最基本的中斷點教學之外, 還有條件式中斷的教學 條件式中斷是進階的除錯技巧, 在某些特定情況中, 我們有一個函數可能會被呼叫數次, 但是我們只希望在某種條件成立時才進行中斷, 進而觀察變數的狀態 而條件式中斷這項技巧正是符合這項需求 本教學分兩部分 單步除錯 (Page2~11, 共 10) 條件式中斷點 (Page12~17, 共 6)

More information

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

用手機直接傳值不透過網頁連接, 來當作搖控器控制家電 ( 電視遙控器 ) 按下按鍵發送同時會回傳值來確定是否有送出 問題 :1. 應該是使用了太多 thread 導致在傳值上有問題 2. 一次按很多次按鈕沒辦法即時反應 專題進度 老師 : 趙啟時老師 學生 : 陳建廷 2013/10/13 用手機直接傳值不透過網頁連接, 來當作搖控器控制家電 ( 電視遙控器 ) 按下按鍵發送同時會回傳值來確定是否有送出 問題 :1. 應該是使用了太多 thread 導致在傳值上有問題 2. 一次按很多次按鈕沒辦法即時反應 程式碼 : package com.example.phone; import java.util.arraylist;

More information

建立Android新專案

建立Android新專案 經濟部工業局 Android 智慧型手機程式設計實務應用班 Android WebService 建國科技大學資管系 饒瑞佶 2012/4 WebService 需要 ksoap2-android-assembly-2.5.2-jar-withdependencies.jar 或 ksoap2-android-assembly-2.5.2-jar-withdependencies_timeout1.jar

More information

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

预览图 : (2) 在 SelectCity.java 中增加控件, 用于绑定 select_city 文件的 ListView, TextView,EditTest 等控件 代码和注释如下 : EditText 实现城市搜索 1801210778 邹宇航 摘要 : 使用 EditText 实现搜索城市的功能, 以此为依据更新 ListView 1. 效果图 : 2. 主要步骤 (1) 在 select-city.xml 布局文件中中添加 EditText 控件用作搜索框, 然后添加 ListView 控件用来显示城市名字内容 代码如下 : 预览图 : (2) 在 SelectCity.java

More information

Android 开发教程

Android 开发教程 封面 1 GUI 可视化设计器 DroidDraw DroidDraw 是一个基于 Java Swing 的 Android 界面设计器, 可以通过它来生成复杂的 Android Layout XML 文 件,Android 的 Layout 和 Swing Layout 中有很好的对应, 设计器的代码编写起来比较容易 2 AnDroidDraw AnDroidDraw 是一个与 DroidDraw

More information

Microsoft Word - 第3章.doc

Microsoft Word - 第3章.doc 第 3 章 多个用户界面的程序设计 3.1 页面的切换与传递参数值 3.1.1 传递参数组件 Intent Intent 是 Android 系统的一种运行时的绑定机制, 在应用程序运行时连接两个不同组件 在 Android 的应用程序中不管是页面切换还是传递数据或是调用外部程序都可能要用到 Intent Intent 负责对应用中某次操作的动作 动作涉及的数据 附加数据进行描述, Android

More information

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

Android 编程基础 Android 开发教程 & 笔记 1 Android 开发教程 & 笔记 1 多式样 ProgressBar 撰写 : 地狱怒兽 联系 :zyf19870302@126.com 普通圆形 ProgressBar 该类型进度条也就是一个表示运转的过程, 例如发送短信, 连接网络等等, 表示一个过程正 在执行中 一般只要在 XML 布局中定义就可以了

More information

Microsoft Word - 第3章.doc

Microsoft Word - 第3章.doc 第 章.1 Android UI 基本概念 用户界面 (User Interface,UI) 是用户与设备之间进行信息交流的直接媒介, 是决定用户体验最重要的部分 相比于早期的计算机的主要交互界面 批处理界面和命令行界面, 现在更为流行的是更简单直接的用户图形界面 (Graphical User Interface, GUI) GUI 简单易用, 受众面广, 直接推动了个人计算机的发展 目前, 主流大众的操作系统都采用了

More information

Chapter 9: Objects and Classes

Chapter 9: Objects and Classes Java application Java main applet Web applet Runnable Thread CPU Thread 1 Thread 2 Thread 3 CUP Thread 1 Thread 2 Thread 3 ,,. (new) Thread (runnable) start( ) CPU (running) run ( ) blocked CPU sleep(

More information

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

Microsoft PowerPoint - 07.Android 介面元件-TableLayout、Toast、AlertDialog 計劃名稱 : 104 年度教育部資通訊軟體創新人才推升推廣計畫跨校資源中心 : 雲端運算 ( 國立中山大學 ) 課程名稱 : 網路及平台服務 Part1- 課程教材 教材名稱 :Android 介面元件 -TableLayout Toast AlertDialog 國立高雄大學資訊工程學系張保榮教授 大綱 TableLayout 版面配置 Toast 版面配置 AlertDialog 版面配置 TableLayout

More information

Microsoft Word - 02.目錄.doc

Microsoft Word - 02.目錄.doc 目錄 -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. 畫廊展示...

More information

untitled

untitled JavaEE+Android - 6 1.5-2 JavaEE web MIS OA ERP BOSS Android Android Google Map office HTML CSS,java Android + SQL Sever JavaWeb JavaScript/AJAX jquery Java Oracle SSH SSH EJB+JBOSS Android + 1. 2. IDE

More information

RecyclerView and CardVew

RecyclerView and CardVew RecyclerView and CardView 建國科技大學資管系饒瑞佶 2017/10 V1 CardView CardView A CardView is a ViewGroup. Like any other ViewGroup, it can be added to youractivity or Fragment using a layout XML file. To create an

More information

PowerPoint 簡報

PowerPoint 簡報 UI 設計 Android 專案目錄架構 Android 專案建立後會自動產生 3 個主要目錄 src:java 程式檔案 res: 資源 ( 文字 圖形 聲音檔案等 ) 與 UI 設定有關的 layout 檔 此目錄內檔案名稱只能為小寫字母 數字 _. gen:r.java 根據 res 目錄內容自動產生 不要去修改 R.java Android 中所有的資源檔案 ( 圖片 XML 等 ) 命名都必須使用英文小寫,

More information

第6讲

第6讲 UI 及 图 形 应 用 开 发 技 术 哈 尔 滨 工 业 大 学 软 件 学 院 唐 好 选 Email:tanghx@hit.edu.cn 主 要 内 容 Android UI 布 局 图 形 控 件 常 用 的 XML 属 性 图 形 界 面 中 常 用 的 控 件 元 素 菜 单 对 话 框 Android 的 UI 布 局 为 了 适 应 各 式 各 样 的 界 面 风 格,Android

More information

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

0511-Android程式之GPS應用_專題週記4 逢甲大學通訊工程學系專題研究 Android 程式之 GPS 應用 專題週記 0511 學生姓名 陳彥儒 D0035131 廖元譽 D0077791 指導老師 楊豐瑞老師繳交日期 2014.05.11 1 匯入 GoogleMap 1.1 取得授權步驟 目前進度 取得 Google 授權鑰匙 實作程式尚未成功 1.1.1 建立個人的 keystore 1.1.2 由個人的 keystore 查詢 SHA1

More information

Microsoft Word - 01.DOC

Microsoft Word - 01.DOC 第 1 章 JavaScript 简 介 JavaScript 是 NetScape 公 司 为 Navigator 浏 览 器 开 发 的, 是 写 在 HTML 文 件 中 的 一 种 脚 本 语 言, 能 实 现 网 页 内 容 的 交 互 显 示 当 用 户 在 客 户 端 显 示 该 网 页 时, 浏 览 器 就 会 执 行 JavaScript 程 序, 用 户 通 过 交 互 式 的

More information

投影片 1

投影片 1 資料庫管理程式 ( 補充教材 -Part2) 使用 ADO.NET 連結資料庫 ( 自行撰寫程式碼 以實現新增 刪除 修改等功能 ) Private Sub InsertButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InsertButton.Click ' 宣告相關的 Connection

More information

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

Microsoft PowerPoint - 05.Android 介面元件-RelativeLayout、Button、TextVeiw、EditText 計劃名稱 : 104 年度教育部資通訊軟體創新人才推升推廣計畫跨校資源中心 : 雲端運算 ( 國立中山大學 ) 課程名稱 : 網路及平台服務 Part1- 課程教材 教材名稱 :Android 介面元件 -RelativeLayout Button TextVeiw EditText 國立高雄大學資訊工程學系張保榮教授 大綱 RelativeLayout 版面配置 Button 版面配置 TextView

More information

書面

書面 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 5.4 互動功能畫面 程式碼請參考附件-程式三 在進入互動頁面時 會執行setAllText()依寵物狀態數值來 設定狀態文字與頭像 並且依心情決定是否要不要播放音效 觸摸的區域 由於是自己寫的 view 所以並未透過xml來設置 而是透過Layut.addview()來動態新增

More information

ShareText

ShareText 作者 : 林致宇 日期 :2012/1/23 問題 : 如何分享分享文字資訊給其它的應用程式? 解答 : 有時候我們可能會希望 我們的應用程式的資訊 能夠讓使用者分享出去, 讓使用者能夠將此資訊傳送簡訊給其好友或寄電子郵件的方式寄給其好友, 這份文件將示範如何寫出這樣的應用程式 本文件將產出兩個 App, 第一個 App 是 分享資料的來源, 名為 CopyPaste_Source, 功能非常簡單,

More information

Microsoft Word - Android 7.x.doc

Microsoft Word - Android 7.x.doc 第 4 章 Android GUI 开发 Android 系统提供了丰富的可视化界面组件, 包括菜单 按钮 对话框等 Android 系统采用 Java 程序设计中的 UI 设计思想, 其中包括事件处理机制及布局管理方式 Android 系统中的所有 UI 类都是建立在 View 和 ViewGroup 两个类的基础之上的, 所有 View 的子类称为 Widget, 所有 ViewGroup 的子类称为

More information

投影片 1

投影片 1 Chapter 13 Android 實戰演練 線上匯率查詢 線上匯率查詢 本節範例將實作一個簡單的線上費率查詢, 利用 Url 查詢台灣銀行的即時匯率, 欲查詢的網址為 http://rate.bot.com.tw/pages/static/uip003.zh- TW.htm 此網頁中每隔幾分鐘會更新一次匯率, 所以範例程式在一開啟時會抓取此網頁並將網頁內容解析後將匯率資料取出 線上匯率查詢 台灣銀行線上即時匯率查詢

More information

Chapter 10

Chapter 10 Chapter 10 多媒體程式開發 Widget Widget 簡介 android.widget 套件包含了許多視覺性的 UI 元素, 可用來將操作界面展示在應用程式畫面上 要熟悉 Android 多媒體程式的開發, 必須從 widget 套件著手, 因此本章所舉的範例, 便是以 android.widget 套件的應用為中心 Gallery 簡介 Gallery 是一個水平的清單, 移動清單時,

More information

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

詞 彙 表 編 號 詞 彙 描 述 1 預 約 人 資 料 中 文 姓 名 英 文 姓 名 身 份 證 字 號 預 約 人 電 話 性 別 2 付 款 資 料 信 用 卡 別 信 用 卡 號 信 用 卡 有 效 日 期 3 住 房 條 件 入 住 日 期 退 房 日 期 人 數 房 間 數 量 入 100 年 特 種 考 試 地 方 政 府 公 務 人 員 考 試 試 題 等 別 : 三 等 考 試 類 科 : 資 訊 處 理 科 目 : 系 統 分 析 與 設 計 一 請 參 考 下 列 旅 館 管 理 系 統 的 使 用 案 例 圖 (Use Case Diagram) 撰 寫 預 約 房 間 的 使 用 案 例 規 格 書 (Use Case Specification), 繪 出 入

More information

人民邮电

人民邮电 第 2 章 布 局 布 局 是 所 有 带 界 面 的 Android 程 序 的 开 端 布 局 应 用 得 好 坏 直 接 决 定 了 程 序 的 用 户 体 验 虽 然 布 局 看 似 没 有 组 件 复 杂, 但 也 涉 及 到 了 很 多 技 巧 在 各 大 公 司 的 面 试 题 中 也 会 经 常 遇 到 关 于 布 局 的 一 些 问 题 通 过 这 些 问 题 可 以 考 查 应

More information

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

1: public class MyOutputStream implements AutoCloseable { 3: public void close() throws IOException { 4: throw new IOException(); 5: } 6: Chapter 15. Suppressed Exception CH14 Finally Block Java SE 7 try-with-resources JVM cleanup try-with-resources JVM cleanup cleanup Java SE 7 Throwable getsuppressed Throwable[] getsuppressed() Suppressed

More information

Android Android Android SDK iv

Android Android Android SDK iv Android Market Google Android SDK Apple Google Microsoft b2c b 2010 Internet Android how why iii Android 240... Android Android SDK iv Android Market Google Android SDK Visual C++ Java N-tier J2EE Unix/Linux

More information

untitled

untitled 1 行 行 行 行.NET 行 行 類 來 行 行 Thread 類 行 System.Threading 來 類 Thread 類 (1) public Thread(ThreadStart start ); Name 行 IsAlive 行 行狀 Start 行 行 Suspend 行 Resume 行 行 Thread 類 (2) Sleep 行 CurrentThread 行 ThreadStart

More information

雲端 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

雲端 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 CHAPTER 使用 Hadoop 打造自己的雲 8 8.3 測試 Hadoop 雲端系統 4 Nodes Hadoop Map Reduce Hadoop WordCount 4 Nodes Hadoop Map/Reduce $HADOOP_HOME /home/ hadoop/hadoop-0.20.2 wordcount echo $ mkdir wordcount $ cd wordcount

More information

投影片 1

投影片 1 Chapter 12 Android 動畫程式設計 前言 Android 在動畫程式設計上有非常多成熟的工具可以使用 例如說 :Canvas 畫布 ViewFlipper 動畫等, 另外也可以使用 OpenGL 去設計 2D/3D 圖形或動畫, 使手機多媒體或是操作介面有更多爆炸性的發展 畫布 / 畫筆 Canvas Canvas 物件在 Java 應用程式上已經非常成熟, 用於 Android 上也是開發動畫或

More information

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

任務二 : 產生 20 個有炸彈的磚塊, 放在隨機的位置編輯 Block 類別的程式碼 import greenfoot.; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) Write a description of class 踩地雷遊戲 高慧君南港高中 開啟專案 MineSweep 任務一 : 產生 30X20 個磚塊編輯 Table 類別的程式碼 import greenfoot.; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.util.arraylist; Write a description of class MyWorld

More information

1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10

1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10 Java V1.0.1 2007 4 10 1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10 6.2.10 6.3..10 6.4 11 7.12 7.1

More information

单击以编辑母片 Content 标题样式 LinearLayout 排版模式 TableLayout 排版模式 RelativeLayout 排版模式 AbsoluteLayout 排版模式 FrameLayout 排版模式 GridLayout 排版模式 TabWidget 切換卡 Lab 5 2

单击以编辑母片 Content 标题样式 LinearLayout 排版模式 TableLayout 排版模式 RelativeLayout 排版模式 AbsoluteLayout 排版模式 FrameLayout 排版模式 GridLayout 排版模式 TabWidget 切換卡 Lab 5 2 单击以编辑母片标题样式 安卓系统 Android 的排版 授课老师 : 谢兆贤 2016/4/18 1 单击以编辑母片 Content 标题样式 LinearLayout 排版模式 TableLayout 排版模式 RelativeLayout 排版模式 AbsoluteLayout 排版模式 FrameLayout 排版模式 GridLayout 排版模式 TabWidget 切換卡 Lab 5

More information

實作SQLiteOpenHelper類別

實作SQLiteOpenHelper類別 SQLiteOpenHelper 類別存取 SQLite 建國科技大學資管系 饒瑞佶 2013/5 V1 Android 連結資料庫 MySQL SQL Server Web Service 遠端資料庫 Internet Intranet Android SQLite 單機資料庫 Android vs. SQLite 透過 SQLiteOpenHelper 類別來操作 建立資料庫 ( 建構子 ) 建立資料表

More information

建立Android新專案

建立Android新專案 Android 智 慧 型 手 機 程 式 設 計 Android WebService 建 國 科 技 大 學 資 管 系 饒 瑞 佶 2012/4 V1 2012/8 V2 2013/5 V3 2014/10 v4 提 醒 這 節 的 內 容 針 對 的 是 MS 的 Web Service 或 是 使 用 SOAP(Simple Object Access Protocol) 標 準 建 立

More information

建模与图形思考

建模与图形思考 C03_c 基 於 軟 硬 整 合 觀 點 JNI: 从 C 调 用 Java 函 数 ( c) By 高 煥 堂 3 How-to: 基 於 軟 硬 整 合 觀 點 从 C 调 用 Java 函 数 如 果 控 制 点 摆 在 本 地 C 层, 就 会 常 常 1. 从 本 地 C 函 数 去 调 用 Java 函 数 ; 2. 从 本 地 C 函 数 去 存 取 Java 层 对 象 的 属 性

More information

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

輕鬆學 Dreamweaver CS5 網頁設計..\Example\Ch0\ \.html..\example\ch0\ \mouse.txt..\example\ch0\ \ _Ok.html 學習重點 JavaScript 複製程式碼 mouse.txt Ctrl+C Ctrl+C 0-4 JAVA Extension 0..\Example\Ch0\ \ T.html..\Example\Ch0\ \ T.txt T.txt..\Example\Ch0\ \ T_Ok.html 提示 :. Marquee Marquee Font Color #FFFFFF BG Color #867bf Width 90 Height 50. T.txt Ctrl+C your scrolling

More information

Microsoft Word - 第3章.doc

Microsoft Word - 第3章.doc 第 3 章 Android 控件进阶 要设计出让用户喜欢的 Android 应用程序界面, 除了需要用到在第 2 章讲的最基本的 TextView EditText 和 Button 控件外, 还要用到其他控件, 如 ImageButton 控件 ImageView 控件 RadioButton 控件 CheckBox 控件和 ListView 控件等 本章主要讲解功能强大 应用广泛的一些控件 3.1

More information

PowerPoint 簡報

PowerPoint 簡報 Paint 繪圖板 JAVA 程式設計 指導老師 : 鄞宗賢 組員 : 4A3G0901 劉彥佐 4A3G0907 韓偉志 畫面預覽 匯入參數 package paint; import java.awt.*; import java.awt.event.*; import javax.swing.*; 主程式 public class paint{ public static void main(string[]

More information

投影片 1

投影片 1 Chapter 11 Google 服務應用開發 Google 服務應用開發 Google 提供了許多免費服務, 例如搜尋引擎 Google Map Google 翻譯 Google 文件 Google 日曆 GMail Google Talk Youtube 等常見的服務,Google 擁有大量的資料以及對這些資料作分析的能力, 因此可以提供更多元的服務類型 在豐富的資源下將 Google 服務與

More information

Android + NFC

Android + NFC Android + NFC 建國科技大學資管系饒瑞佶 2017/3 v1 讀取 Tag UUID Android 2.3.3 (API Level 10) 才有支援完整的 NFC 功能 只要 NFC 相容都讀的到 (NFC 或 Mifare) 建立新專案修改 AndroidManifest.xml 加入 , 如果有 NFC Tag 進入感測範圍, 本 App 也會變成可處理的

More information

untitled

untitled 1 Outline 數 料 數 數 列 亂數 練 數 數 數 來 數 數 來 數 料 利 料 來 數 A-Z a-z _ () 不 數 0-9 數 不 數 SCHOOL School school 數 讀 school_name schoolname 易 不 C# my name 7_eleven B&Q new C# (1) public protected private params override

More information

Microsoft Word - 第5章.doc

Microsoft Word - 第5章.doc 第 5 课 Android 基 础 控 件 详 解 Android 应 用 程 序 的 人 机 交 互 界 面 有 很 多 Android 控 件 组 成 几 乎 所 有 的 Android 都 会 涉 及 到 控 件 技 术, 如 文 本 框 编 辑 框 按 钮 列 表 等 控 件 这 些 在 Android 应 用 程 序 中 随 处 可 见, 本 课 将 对 Android 提 供 的 基 础

More information

基于ECO的UML模型驱动的数据库应用开发1.doc

基于ECO的UML模型驱动的数据库应用开发1.doc ECO UML () Object RDBMS Mapping.Net Framework Java C# RAD DataSetOleDbConnection DataGrod RAD Client/Server RAD RAD DataReader["Spell"].ToString() AObj.XXX bug sql UML OR Mapping RAD Lazy load round trip

More information

概述

概述 OPC Version 1.6 build 0910 KOSRDK Knight OPC Server Rapid Development Toolkits Knight Workgroup, eehoo Technology 2002-9 OPC 1...4 2 API...5 2.1...5 2.2...5 2.2.1 KOS_Init...5 2.2.2 KOS_InitB...5 2.2.3

More information

Microsoft Word - Chap04.doc

Microsoft Word - Chap04.doc 04-26 ICON 此範例將說明設定離開與關閉程式的對話視窗提示選項 而啟動這個對話視窗是由一個按鈕來處理, 當按下 按我離開 按鈕時, 會出現 AlertDialog 的訊息, 而 AlertDialog 的內容設定, 先設定是否要顯示 title 的文字 ( 也可以不設定 ), 在此範例是設定為讓它顯示, 所以使用 res/values/string/app_about 這個字串常數 下一步則是顯示

More information

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

Microsoft Word - 第4章 3D相册.doc 第 4 章 3D 相册 学习目标 u 掌握相册界面的开发, 实现相册的立体与倒影效果 在现实生活中, 我们浏览照片时, 不同的相册软件有不同的浏览效果 本章主要实现了一个 3D 效果的相册, 该相册中的图片可以循环滑动展示 4.1 3D 相册 任务综述 相册界面主要是展示一组图片的立体效果, 并显示每个图片的倒影, 左右滑动可以切换不同的图片到 界面的中间位置, 同时在图片下方显示当前图片的标题,

More information

Android 教學

Android 教學 Android 教 學 2012/3/27 Presented by : Wun-ling E-mail: wunling@iir.csie.ncku.edu.tw Advisor: Dr. Chiang 大 綱 Android 介 紹 Android 環 境 設 定 應 用 程 式 架 構 Manifest 定 義 檔 資 源 檔 設 計 UI 元 件 設 計 硬 體 元 件 Sample 2012/3/27

More information

Database_001

Database_001 作者 : 林致宇日期 :2011/10/26 主要參考來源 : http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applicat ions/ 問題 : 如在存取一個已經建立好的資料庫? 解答 : 有一些應用程式會需要讀取已經建立好的資料庫, 例如一個試題測驗應用程式, 裡面的試題可能已經於電腦上, 使用任何的

More information

Microsoft PowerPoint - VB14.ppt

Microsoft PowerPoint - VB14.ppt VB 列表盒 LISTBOX 應用 資科系 林偉川 執行畫面 1 2 1 重要屬性 LISTBOX 物件 (VB6) 新增至 LISTBOX 物件中 ADDITEM 自 LISTBOX 物件中刪除選取物件 REMOVEITEM 自 LISTBOX 物件中取出選取物件 ListIndex 顯示 LISTBOX 物件中紀錄個數 Listcount 3 LISTBOX 物件 (VB.NET) 重要屬性 新增至

More information

Android 开发教程

Android 开发教程 封面 1 文件存取编程基础 文件 文件可以用来存储比使用引用更大数量的数据 Android 提供方法来读 写文件 只有本地文件可以被访问 优点 : 可以存储大容量的数据 缺点 : 文件更新或是格式改变可能会导致巨大的编程工作 文件操作 读文件 Context.openFileInput(String name) 打开一个与应用程序联系的私有文件输入流 当文件不存在时抛出 FileNotFoundException

More information

中 文 摘 要 智 慧 型 手 機 由 於 有 強 大 的 功 能, 以 及 優 渥 的 便 利 性, 還 能 與 網 路 保 持 隨 時 的 鏈 結 與 同 步 更 新, 因 此 深 受 廣 大 消 費 者 喜 愛, 當 然, 手 機 遊 戲 也 成 為 現 代 人 不 可 或 缺 的 娛 樂 之

中 文 摘 要 智 慧 型 手 機 由 於 有 強 大 的 功 能, 以 及 優 渥 的 便 利 性, 還 能 與 網 路 保 持 隨 時 的 鏈 結 與 同 步 更 新, 因 此 深 受 廣 大 消 費 者 喜 愛, 當 然, 手 機 遊 戲 也 成 為 現 代 人 不 可 或 缺 的 娛 樂 之 臺 北 市 大 安 高 級 工 業 職 業 學 校 資 訊 科 一 百 零 一 學 年 度 專 題 製 作 報 告 ------ 以 Android 製 作 ------ ----- 連 線 塔 防 遊 戲 ------ Tower defense game using Internet technology 班 級 : 資 訊 三 甲 組 別 : A9 組 組 員 : 葉 冠 麟 (9906129)

More information

Microsoft Word - weather12 刷新按钮动画+搜索框+bug处理.docx

Microsoft Word - weather12 刷新按钮动画+搜索框+bug处理.docx 一 刷新按钮的动画效果 : 在刷新按钮的位置做两个按钮的布局, 一个是原来的静态图片, 一个是旋转的动画, 然 后控制这两个效果的显示和隐藏 ( 一 ) 刷新按钮的 style: 1. 在 app/src/main/res/values/ styles.xml 文件里添加一个 style: 2. 在 drawable 文件夹下新建一个 title_update_anim.xml, 添加如下内容 注

More information

EJB-Programming-4-cn.doc

EJB-Programming-4-cn.doc EJB (4) : (Entity Bean Value Object ) JBuilder EJB 2.x CMP EJB Relationships JBuilder EJB Test Client EJB EJB Seminar CMP Entity Beans Session Bean J2EE Session Façade Design Pattern Session Bean Session

More information

Microsoft Word - AEL CH05.doc

Microsoft Word - AEL CH05.doc 5-2 AutoCompleteTextView AutoCompleteTextView 非常類似 EditText, 屬於文字輸入方塊 ; 不過 AutoCompleteTextView 會在使用者輸入幾個字時就會顯示提示文字, 方便使用者選取而無需輸入所有文字, 是一種體貼使用者輸入的設計 AutoCompleteTextView 的提示列表與 Spinner 的選項列表建立方式相同, 需要建立字串陣列來儲存欲提示的文字

More information

第一章 Android 简介与开发环境搭建

第一章 Android 简介与开发环境搭建 安卓开发环境与常用布局 第一章 Android 简介与开发环境搭建 本章目标 3G 的概念 Android 的改变 Android 开发环境的搭建编写第一个 Android 程序 Android 程序的目录结构 手机发展史 1. 3G 的概念 3G 全称为 :3rd Generation, 中文含义即为第三代数字通信, 是指将无线通信与国际互联网等多媒体通信结合的新一代移动通信系统 2. 符合 3G

More information

Microsoft Word - 扉页.doc

Microsoft Word - 扉页.doc 第 3 章 Andro 常用基本控件 我们在进行界面布局时, 添加的按钮 文本框 编辑框和图片等, 都是 Andro 的基本控件 这些控件实现了程序的一些基本功能 本章将针对这类控件进行详细的介绍, 使读者掌握基本控件的使用, 开发出简单的 Andro 程序 3.1 文本控件概述 Andro 系统提供给用户已经封装好的界面控件称为系统控件 系统控件更有利于帮助用户进行快速开发, 同时能够使 Andro

More information

Introduction Android 应用开发课程介绍 本课程旨在通过 6 个基本任务和相关的知识点, 让学习者在短时间内通过任务驱动的方式快速学习掌握 Android 的基本编程 本在线教程与温州大学 SPOC 对接, 可在 SPOC 中观看具体的视频, 帮助完成实现各基本任务 本在线教程目前

Introduction Android 应用开发课程介绍 本课程旨在通过 6 个基本任务和相关的知识点, 让学习者在短时间内通过任务驱动的方式快速学习掌握 Android 的基本编程 本在线教程与温州大学 SPOC 对接, 可在 SPOC 中观看具体的视频, 帮助完成实现各基本任务 本在线教程目前 目錄 Introduction 认识 Android 开发 (Eclipse 版 ) 任务 1:UI 布局编程任务 1- 具体任务任务 1 知识点任务 2:UI 列表编程任务 2- 具体任务任务 2 知识点任务 3:UI 菜单编程任务 3- 具体任务任务 3 知识点任务 4:Http 编程任务 4- 具体任务任务 4 知识点任务 5: 数据库编程任务 5- 具体任务任务 5 知识点任务 6:Excel

More information

Lecture01_Android介绍

Lecture01_Android介绍 移动平台应用软件开发 Android 介绍 主讲 : 张齐勋 zhangqx@ss.pku.edu.cn 移动平台应用软件开发 课程建设小组 北京大学 二零一七年秋北京 Android是什么 Android不仅仅是一个操作系统 它更是一个完整的软件框 架 Android基于Linux内核 2005年Google公司收购了Android公司 Google公司选择使用Apache许可证开放Android源码

More information

(TestFailure) JUnit Framework AssertionFailedError JUnit Composite TestSuite Test TestSuite run() run() JUnit

(TestFailure) JUnit Framework AssertionFailedError JUnit Composite TestSuite Test TestSuite run() run() JUnit Tomcat Web JUnit Cactus JUnit Java Cactus JUnit 26.1 JUnit Java JUnit JUnit Java JSP Servlet JUnit Java Erich Gamma Kent Beck xunit JUnit boolean JUnit Java JUnit Java JUnit Java 26.1.1 JUnit JUnit How

More information

untitled

untitled 1 .NET 利 [] [] 來 說 切 切 理 [] [ ] 來 說 拉 類 類 [] [ ] 列 連 Web 行流 來 了 不 不 不 流 立 行 Page 類 Load 理 Response 類 Write 料 Redirect URL Response.Write("!! ives!!"); Response.Redirect("WebForm2.aspx"); (1) (2) Web Form

More information

46 2011 11 467 數位遊戲式學習系統 7 2011 11 467 47 3 DBGameSys 48 2011 11 467 正規化資料模組 如何配置並儲存電子化資料 以 便減少資料被重覆儲存的程序 DBGameSys的主要功能模組包 學習者 審核評分模組 含 正規化資料模組 審核評分 模組 高分列表模組3大區塊 系統資料庫 在正規化資料模組的執行 高分列表模組 過程中 先要求學習者瀏覽遊戲

More information

小应用 Magic8

小应用 Magic8 胡家威 计研135班 http://hujiaweibujidao.github.io/ 小应用 Magic8 Android 系统简介 Android 应用结构 Android 四大组件 Activity 生命周期 Android 资源管理 UI 组件和容器组件 内容概要 ( 上 ) Android 系统简介 Android 市场份额 Android 是如何诞生的? Android 之父 :Andy

More information

建模与图形思考

建模与图形思考 F06_c 观摩 :ContentProvider 基於軟硬整合觀點 架构與 DB 引擎移植方法 ( c) By 高煥堂 4 通用性基类 ContentProvider 基於軟硬整合觀點 的使用范例 刚才的范例里, 我们直接使用 DataPersist 类的接口来与 SQLite 沟通 本节将替 DataPersist 配上 ContentProvider 基类, 让 Client 能透过 ContentProvider

More information

CU0594.pdf

CU0594.pdf 8 SOHO 1 3 003 SOHO SOHO Coder Programmer HTML CSS PHP JavaScrip 009 LECTURE 1-1 1 048 PART 2 LECTURE 1-1 1 049 SOHO Landing Page Landing 050 PART 2 LECTURE 1-1 1 SEO SEO P.093 SEO SEO SEO SEO SEO 051

More information

3.1 num = 3 ch = 'C' 2

3.1 num = 3 ch = 'C' 2 Java 1 3.1 num = 3 ch = 'C' 2 final 3.1 final : final final double PI=3.1415926; 3 3.2 4 int 3.2 (long int) (int) (short int) (byte) short sum; // sum 5 3.2 Java int long num=32967359818l; C:\java\app3_2.java:6:

More information

epub83-1

epub83-1 C++Builder 1 C + + B u i l d e r C + + B u i l d e r C + + B u i l d e r C + + B u i l d e r 1.1 1.1.1 1-1 1. 1-1 1 2. 1-1 2 A c c e s s P a r a d o x Visual FoxPro 3. / C / S 2 C + + B u i l d e r / C

More information

1. 2. Flex Adobe 3.

1. 2. Flex Adobe 3. 1. 2. Flex Adobe 3. Flex Adobe Flex Flex Web Flex Flex Flex Adobe Flash Player 9 /rich Internet applications/ria Flex 1. 2. 3. 4. 5. 6. SWF Flash Player Flex 1. Flex framework Adobe Flex 2 framework RIA

More information

Microsoft Word - Android App开发从入门到精通.doc

Microsoft Word - Android App开发从入门到精通.doc 第 2 章 Android 控件 本章主要介绍 Android 中常用的控件及其使用方法,Android SDK 本身给我们提供大量的 UI 控件, 合理熟练地使用这些控件才能做出优美的界面 有时候 Android 自带的控件不一定能满足业务需求, 所以本章还会介绍自定义控件 2.1 View 介绍 在 Android 开发中,Android 的 UI 界面都是由 View 及其派生类组合而成的 View

More information

可 Web 编程的NativeUI 设计与实现

可 Web 编程的NativeUI  设计与实现 可 Web 编程的 NativeUI 设计与实现 张袁炜 zhangyuanwei@baidu.com 欢迎转岗简历请发 About Me @ 张袁炜 直达号 网址导航 百度 音乐 前端 Node.js Android Arduino RaspberryPI https://github.com/zhangyuanwei Outline 一个 Hybrid App 的进化史 Native UI 实现原理

More information

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

Microsoft Word - 第1章 Android基本概念.docx Android 系 统 下 Java 编 程 详 解 作 者 : 华 清 远 见 第 1 章 Android 基 本 概 念 本 章 简 介 本 章 主 要 介 绍 Android 基 本 概 念 方 面 的 内 容, 包 括 Android 平 台 特 性 Android 系 统 架 构 Android 开 发 框 架 和 Android 开 发 环 境 搭 建 1.1 Android 简 介 Android

More information

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

840 提示 Excel - Excel -- Excel (=) Excel ch0.xlsx H5 =D5+E5+F5+G5 (=) = - Excel 00 Excel - - Excel - -4-5 840 提示 Excel - Excel -- Excel (=) Excel ch0.xlsx H5 =D5+E5+F5+G5 (=) = - Excel 00 ( 0 ) 智慧標籤 相關說明提示 -5 -- Excel 4 5 6 7 8 + - * / % ^ = < >= & 9 0 (:) (,) ( ) Chapter - :,

More information

Lecture01_Android介绍

Lecture01_Android介绍 移动平台应用软件开发 Android 介绍 主讲 : 张齐勋 zhangqx@ss.pku.edu.cn 移动平台应用软件开发 课程建设小组 北京大学 二零一八年秋北京 Android 是什么 Android 不仅仅是一个操作系统, 它更是一个完整的软件框架 Android 基于 Linux 内核 2005 年 Google 公司收购了 Android 公司 Google 公司选择使用 Apache

More information

图 6-1 主界面 MainActivity 界面对应的布局文件 (activity_main.xml) 如下所示 : <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="

图 6-1 主界面 MainActivity 界面对应的布局文件 (activity_main.xml) 如下所示 : <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android= 第 6 章广播接收者 应用案例 案例 6-1 CallRecord( 通话记录 ) 一 案例描述 1 考核知识点 030006001: 广播接收者简介 030006002: 广播接收者的创建 2 练习目标 广播的静态注册和使用 使用广播处理处理事件 3 需求分析手机最重要的功能就是通话功能, 同样储存通话记录也是必不可少的 该案例使用广 播接收者自己实现通话记录的功能 包括呼出电话 已接来电 未接来电以及通话产生的

More information

KillTest 质量更高 服务更好 学习资料 半年免费更新服务

KillTest 质量更高 服务更好 学习资料   半年免费更新服务 KillTest 质量更高 服务更好 学习资料 http://www.killtest.cn 半年免费更新服务 Exam : 310-055Big5 Title : Sun Certified Programmer for the Java 2 Platform.SE 5.0 Version : Demo 1 / 22 1. 11. public static void parse(string str)

More information

XXX说明书

XXX说明书 实验 1 Android SDK 开发环境的安装及配置 1.1 实验目的 掌握 Java SDK 和 Android SDK 开发环境的安装和配置 1.2 实验内容 Java SDK 的安装和环境变量的配置 Eclipse 的安装和配置 Android SDK 的安装和环境变量的配置 Eclipse 插件 ADT 的安装和配置 Android 模拟器的配置 1.3 实验步骤 1.Java SDK 的安装和环境变量的配置

More information

0 0 = 1 0 = 0 1 = = 1 1 = 0 0 = 1

0 0 = 1 0 = 0 1 = = 1 1 = 0 0 = 1 0 0 = 1 0 = 0 1 = 0 1 1 = 1 1 = 0 0 = 1 : = {0, 1} : 3 (,, ) = + (,, ) = + + (, ) = + (,,, ) = ( + )( + ) + ( + )( + ) + = + = = + + = + = ( + ) + = + ( + ) () = () ( + ) = + + = ( + )( + ) + = = + 0

More information

Spyder Anaconda Spyder Python Spyder Python Spyder Spyder Spyder 開始 \ 所有程式 \ Anaconda3 (64-bit) \ Spyder Spyder IPython Python IPython Sp

Spyder Anaconda Spyder Python Spyder Python Spyder Spyder Spyder 開始 \ 所有程式 \ Anaconda3 (64-bit) \ Spyder Spyder IPython Python IPython Sp 01 1.6 Spyder Anaconda Spyder Python Spyder Python Spyder Spyder 1.6.1 Spyder 開始 \ 所有程式 \ Anaconda3 (64-bit) \ Spyder Spyder IPython Python IPython Spyder Python File

More information

Microsoft PowerPoint - 04 界面编程.ppt [兼容模式]

Microsoft PowerPoint - 04 界面编程.ppt [兼容模式] 手机应用平台软件开发 4 界面编程 刘宁 Email:liuning2@mail.sysu.edu.cn UI 简介 UI(User Interface) 用户界面系统和用户之间进行交互和信息交换的媒介, 主要作用是实现信息内部形式与人类可接受形式之间的转换 人机交互实践中, 一个好的界面设计不仅让软件变得更加有个性和创意, 同时还能让软件的操作变得舒适 简单 自由, 充分体现软件的定位和特点 一个友好美观的界面会给人带来舒适的视觉享受,

More information

Microsoft PowerPoint - Lab 2-3 Android Google Maps.ppt [相容模式]

Microsoft PowerPoint - Lab 2-3 Android Google Maps.ppt [相容模式] 車輛定位與電子地圖整合服務 定位與 Google Maps Network Optimization Lab Department of Computer Science National Chiao Tung University 1 定位與 Google Maps Lab 簡介 : 路徑軌跡記錄程式 Google Maps 程式技巧 取得目前位置經緯度 建立 Google Maps 標示目前位置

More information

製作輸入框組件 Design 編輯模式 編輯模式 :Text(activity_main.xml) 製作輸入框組件 Text 編輯模式 4 Android

製作輸入框組件 Design 編輯模式 編輯模式 :Text(activity_main.xml) 製作輸入框組件 Text 編輯模式 4 Android Android 文字輸入框可分成三類 : 一般輸入框 : 文字 數字 日期 時間 電話與 email 格式... 等 密碼輸入框 : 文數字型與數字型 自動提示框 : 單筆自動提示 多筆自動提示 其顯示樣式以下針對範例程式 CH06_04_EditText 來作說明 執行結果 : EditText android:hint AutoCompleteTextView 輸入框組件執行結果 CH06_04_EditText

More information

untitled

untitled 1 LinkButton LinkButton 連 Button Text Visible Click HyperLink HyperLink 來 立 連 Text ImageUrl ( ) NavigateUrl 連 Target 連 _blank _parent frameset _search _self 連 _top 例 sample2-a1 易 連 private void Page_Load(object

More information

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

目 錄 一 ANDROID 開發系統需求 作業系統 開發工具... 1 二 安裝 ANDROID 開發工具 安裝 JDK 使用 APT-GET 安裝 使用套件管理程式安裝... 9 三 ANDROID 程式撰寫... 1 Android On Linux 簡易安裝開發教學 Installing Google Android SDK 2.0.1 On Ubuntu 9.10 Desktop 目 錄 一 ANDROID 開發系統需求... 1 1. 作業系統... 1 2. 開發工具... 1 二 安裝 ANDROID 開發工具... 1 1. 安裝 JDK... 1 2. 使用 APT-GET 安裝... 2 3. 使用套件管理程式安裝...

More information

AutoCAD 用戶如何使用 ArchiCAD

AutoCAD 用戶如何使用 ArchiCAD AutoCAD 用戶如何使用 ArchiCAD AutoCAD用戶如何使用ArchiCAD ( 中文版 ) 由 Scott MacKenzie, Simon Gilbert, Geoffrey Moore Langdon, David Byrnes, Ralph Grabowski 編寫 龍庭資訊有限公司 1/73 - 2. 3. 4. -

More information

Microsoft PowerPoint - chapter05.ppt

Microsoft PowerPoint - chapter05.ppt 第 5 章 Android 用户界面 本章学习目标 了解用户界面基础知识 掌握几个常用界面控件使用方法 掌握界面布局基本方法 掌握菜单设计基本方法 了解 Android 界面框架调用界面控件的事件处理函数对事件进行处理的方法 Android UI 组件概述 应用程序的好坏, 主要有三个元素决定 界面 功能 性能 界面给用户的第一感觉至关重要 UI 的设计与控制是程序开发核心内容之一 Android

More information

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

教育部補助資訊軟體人才培育先導計畫 100 年度課程發展專案計畫 實驗課程名稱 : IPC(Inter-Process Communication) 開發教師 : 張晉源老師 開發學生 : 林政揚 學校系所 : 樹德科技大學資訊工程學系 教育部補助資訊軟體人才培育先導計畫 100 年度課程發展專案計畫 實驗課程名稱 : IPC(Inter-Process Communication) 開發教師 : 張晉源老師 開發學生 : 林政揚 (s11639104@stu.edu.tw) 學校系所 : 樹德科技大學資訊工程學系 實驗目的 本實驗的目的在於讓同學們可以了解 Android 系統核心內部的行程通訊的原理, 透過呼叫系統提供的其中一樣服務

More information

Microsoft Word - PHP7Ch01.docx

Microsoft Word - PHP7Ch01.docx PHP 01 1-6 PHP PHP HTML HTML PHP CSSJavaScript PHP PHP 1-6-1 PHP HTML PHP HTML 1. Notepad++ \ch01\hello.php 01: 02: 03: 04: 05: PHP 06:

More information

untitled

untitled 1 Outline 料 類 說 Tang, Shih-Hsuan 2006/07/26 ~ 2006/09/02 六 PM 7:00 ~ 9:30 聯 ives.net@gmail.com www.csie.ntu.edu.tw/~r93057/aspnet134 度 C# 力 度 C# Web SQL 料 DataGrid DataList 參 ASP.NET 1.0 C# 例 ASP.NET 立

More information

<img>

<img> 04 圖片 4-1 4-2 4-3 4-4 網頁程式設計 4-1 網頁多媒體 Flash Java Applets HTML 8 4-1-1 圖片 JPEG Joint Photographic Experts Group 非失真模式 (lossless) 基本模式 (baseline standard) 1 2 12 JPEG 6 JPEG.jpg.jpe.jpeg GIF (graphic

More information