Android培训班(46)

<!-- @page { margin: 2cm } P { margin-bottom: 0.21cm } A:link { so-language: zxx } -->

在目录res/values里,主要包括界面缺省的资源。比如从前面XML里看到下面这行:

android:text="@string/clear"

这行是指明显示的字符串,但真正要在界面上显示的字符串并不是“@string/clear”,这里仅是指明了索引值,意思就是说从string资源表里找到”clear”的值。那么这个值保存在那里呢?其实是保存在res/values目录的strings.xml文件,当然不同的语言只存在不同的values目录里,这样是很方便android的应用程序进行多国语言开发的,不用修改代码,只修改资源,就可以进行国际化开发了。

下面就是values里的xml文件内容:

<?xml version="1.0" encoding="utf-8"?>

<resources>

这里定义了应用程序的名称。

<!-- Application name -->

<string name="app_name">Calculator</string>

<!-- If there is a syntax error in the user entered calculation, an error dialog will appear. This is the title. -->

<string name="error">Error</string>

<!-- Displayed numbers for the digit buttons -->

<string name="digit0">0</string>

<!-- Displayed numbers for the digit buttons -->

<string name="digit1">1</string>

<!-- Displayed numbers for the digit buttons -->

<string name="digit2">2</string>

<!-- Displayed numbers for the digit buttons -->

<string name="digit3">3</string>

<!-- Displayed numbers for the digit buttons -->

<string name="digit4">4</string>

<!-- Displayed numbers for the digit buttons -->

<string name="digit5">5</string>

<!-- Displayed numbers for the digit buttons -->

<string name="digit6">6</string>

<!-- Displayed numbers for the digit buttons -->

<string name="digit7">7</string>

<!-- Displayed numbers for the digit buttons -->

<string name="digit8">8</string>

<!-- Displayed numbers for the digit buttons -->

<string name="digit9">9</string>

<!-- Button name on screen to delete the last entered digit or operator -->

<string name="del">DELETE</string>

<!-- Button name on screen to clear the entire calculation field -->

//QQ: 9073204 EMAIL:9073204@qq.com

//蔡军生  2011-04-24

这一行就是上面指明要加载显示的字符串。

<string name="clear">CLEAR</string>

定义字符串资源的格式是使用resources标签,然后再使用string标签,属性name是指明字符串的名称。如下:

<resources>

<string name="clear">CLEAR</string>

</resources>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值