2014年8月1日 星期五

觀察: 開發筆記: 3) 版面配置對話框 ,文字資源設定

最後進行版面配置的是編輯筆記對話框。

編輯筆記對話框

版面配置如下圖。



edit.xml

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:orientation="vertical"  
  4.     android:layout_width="fill_parent"  
  5.     android:layout_height="fill_parent"  
  6.     >  
  7.     <RelativeLayout  
  8.         android:id="@+id/title_layout"  
  9.         android:orientation="horizontal"  
  10.         android:layout_width="fill_parent"  
  11.         android:layout_height="wrap_content"  
  12.         >  
  13.         <EditText  
  14.             android:id="@+id/editTitle"  
  15.             android:layout_width="fill_parent"  
  16.             android:layout_height="wrap_content"  
  17.             />  
  18.     </RelativeLayout>  
  19.     <RatingBar  
  20.         android:id="@+id/editPriority"  
  21.         android:numStars="5"  
  22.         android:layout_below="@id/title_layout"  
  23.         android:layout_width="wrap_content"  
  24.         android:layout_height="wrap_content"  
  25.         android:stepSize="1"  
  26.         style="?android:attr/ratingBarStyle"  
  27.         />  
  28.     <ScrollView  
  29.         android:layout_alignParentBottom="true"  
  30.         android:layout_below="@id/editPriority"  
  31.         android:layout_width="fill_parent"  
  32.         android:layout_height="fill_parent"  
  33.         >  
  34.         <EditText  
  35.             android:id="@+id/editCont"  
  36.             android:layout_width="fill_parent"  
  37.             android:layout_height="fill_parent"  
  38.             android:singleLine="false"  
  39.             />  
  40.     </ScrollView>  
  41. </RelativeLayout>  



文字資源設定

這是開發多國語言版本的方法之一,將程式內的顯示文字部分都當作
文字資源物件來處理,於是可以設定成各國不同語言的版本,以後只要新增該國語言的文字資源及成為該國語言的版本。我們先設計中文語系的文字資源檔。

strings.xml
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <resources>  
  3.     <string name="app_name">我的隨身筆記本</string>  
  4.     <string name="priority">重要</string>  
  5.     <string name="note_title">筆記標題</string>  
  6.     <string name="title">標題</string>  
  7.     <string name="delete">刪除</string>  
  8.     <string name="setting">組態設定</string>  
  9.     <string name="notebook">筆記本</string>  
  10.     <string name="garbage">垃圾桶</string>  
  11.     <string name="edit_note">筆記資料</string>  
  12.     <string name="edit_update">異動更新</string>  
  13.     <string name="edit_delete">刪除筆記</string>  
  14.     <string name="default_priority">預設重要等級</string>  
  15.     <string-array name="val_priority">  
  16.         <item>1(最低)</item>  
  17.         <item>2</item>  
  18.         <item>3</item>  
  19.         <item>4</item>  
  20.         <item>5(最高)</item>  
  21.     </string-array>      
  22. </resources>  
參考資料:Google Android 手機 APP 開發入門

沒有留言:

張貼留言