一:基本语法
1、XML 声明
XML 声明文件的可选部分,如果存在需要放在文档的第一行,如下所示:
<?xml version="1.0" encoding="utf-8"?>
以上实例包含 XML 版本(
UTF-8 也是 HTML5, CSS, JavaScript, PHP, 和 SQL 的默认编码。
2、 XML 元素?
XML 元素指的是从(且包括)开始标签直到(且包括)结束标签的部分。
一个元素可以包含:
其他元素
文本
属性
或混合以上所有...
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">SleepAwakeAutoTest</string>
<string name="hello_world">Hello world!</string>
<string name="awake">IMEI NUM:</string>
<string name="second">Second(s)</string>
<string name="sleep">IMEI DISPLAY</string>
<string name="start">write IMEI</string>
<string name="stop">read IMEI</string>
<string name="instruction">Instructions:</string>
<string name="time_instruction"> Awake time is the time of the unsuspend state, Sleep time is of suspend</string>
<string name="operate"> Press Start to start the auto test. Press the Cancel in the nofitcation to stop this test</string>
<string name="sleepawake">SleepAwake</string>
<string name="cancel">Cancel</string>
<string name="action_settings">Settings</string>
<string name="random">Random Mode</string>
<string name="TestTimes">Test times:</string>
<string name="sample_device_admin_description">Descrption of Administration</string>
<string name="sample_device_admin">setAdministration</string>
<string name="Enable">Enable</string>
<string name="Disable">Disable</string>
</resources>
xml占位符:
写一个简单的案例。
在strings.xml中写入
在Activity.java中写入
打印结果为: