<!-- @page { margin: 2cm } P { margin-bottom: 0.21cm } A:link { so-language: zxx } -->
在资源的目录res/values-zh-rCN,从目录的名称就可以看到这个是保存跟中文相关的资源的目录。现在来仔细地查看这个目录的文件strings.xml,内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (C) 2009 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name" msgid="8095131950334945205">"计算器"</string>
<string name="error" msgid="9197457880925804499">"错误"</string>
<string name="digit0" msgid="8069590963464434135">"0"</string>
<string name="digit1" msgid="8535041374797804029">"1"</string>
<string name="digit2" msgid="8977354203154316247">"2"</string>
<string name="digit3" msgid="148544090755132760">"3"</string>
<string name="digit4" msgid="2199490603838247678">"4"</string>
<string name="digit5" msgid="7568514524384173087">"5"</string>
<string name="digit6" msgid="6705952561049362551">"6"</string>
<string name="digit7" msgid="658125644218958447">"7"</string>
<string name="digit8" msgid="3134686906411558886">"8"</string>
<string name="digit9" msgid="765379157698748031">"9"</string>
<string name="del" msgid="6248896117422989693">"删除"</string>
<string name="clear" msgid="895929542545793094">"清除"</string>
<string name="sin" msgid="6793866152659175277">"sin"</string>
<string name="cos" msgid="6901841853098114414">"cos"</string>
<string name="tan" msgid="7957459816738554960">"tan"</string>
<string name="e" msgid="1377847800971731483">"e"</string>
<string name="ln" msgid="6888500680285403344">"ln"</string>
<string name="lg" msgid="873623857385418182">"log"</string>
<string name="leftParen" msgid="4850643713953092099">"("</string>
<string name="rightParen" msgid="3177971166159324016">")"</string>
<string name="basic" msgid="7691469861698059753">"基本面板"</string>
<string name="advanced" msgid="7122495413742976492">"高级面板"</string>
<string name="clear_history" msgid="8458043980601165012">"清除历史记录"</string>
</resources>
//QQ: 9073204 EMAIL:[email protected]
//蔡军生 2011-04-24
从上面的内容可以看到,其实就是一些字符串资源,当android的应用程序变换语言时,变换显示的字符串资源,就可以达到不同的语言显示,这是很方便维护国际化程序的。
到这里,就已经把计算器应用程序的资源分析完成,后面接着来分析它的代码框架和结构,以及具体实现。