java - 错误 : Error parsing XML: unbound prefix

标签 java android xml bluetooth

我在 strings.xml 文件中收到此错误:错误:解析 XML 时出错:未绑定(bind)前缀

<resources>
    <string name="mainTitle">Remote Doctor </string>
    <string name="app_name">Remote Doctor</string>
    <string name="patientButton">Patient Mode </string>
    <string name="doctorButton">Doctor Mode </string>
    <string name="aboutButton">About </string>
    <string name="exit">Exit</string>
    <string name="simpleMode">Simple Mode</string>
    <string name="detailedMode">Detailed Mode</string>
    <string name="aboutTitle">About Remote Doc</string>
    <string name="aboutText">\
    Remote Doc is an application that allows a brace user and the doctor to analyze and record  
    how often the brace is being worn and how much force or pressure the brace is putting on 
    the user       </string> 

    <!--  BluetoothChat -->    
    <string name="send">Send</string>    
    <string name="not_connected">You are not connected to a device</string>    
Error:  <string name="bt_not_enabled_leaving">Bluetooth was not enabled. Leaving Bluetooth Chat.</string>    
    <string name="title_connecting">connecting...</string>    
    <string name="title_connected_to">connected to <xliff:g id="device_name">%1$s</xliff:g></string>    
    <string name="title_not_connected">not connected</string>    
    <!--  DeviceListActivity -->    
    <string name="scanning">scanning for devices...</string>    
    <string name="select_device">select a device to connect</string>    
    <string name="none_paired">No devices have been paired</string>    
    <string name="none_found">No devices found</string>    
    <string name="title_paired_devices">Paired Devices</string>    
    <string name="title_other_devices">Other Available Devices</string>    
    <string name="button_scan">Scan for devices</string>    
    <!-- Options Menu -->    
    <string name="secure_connect">Connect a device - Secure</string>    
    <string name="insecure_connect">Connect a device - Insecure</string>    
    <string name="discoverable">Make discoverable</string>   
</resources>

我做错了什么???

最佳答案

您没有为 <xliff:g id="device_name">%1$s</xliff:g> 定义 XML 命名空间

在现实中你会想逃避 < > xliff:g周围标签。 <string>里面的文字标记作为原始 XML 而不是字符串值的一部分进行处理。

使用此代替 title_connected_to 条目:

<string name="title_connected_to">connected to &lt;xliff:g id="device_name"&gt;%1$s&lt;/xliff:g&gt;<string>

关于java - 错误 : Error parsing XML: unbound prefix,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6918246/

相关文章:

java - java中如何将 'hashtags'的字符串转换为json?

java - 自定义 ArrayAdapter 中无法访问的语句

PHP/SimpleXML - 为单个 child 和多个 child 生成不同的数组

java - 使用 Eclipse 防止将文件提交到 SVN 并发出警告

java - 我的计时器线程可能用 Thread.sleep 欺骗他?

java - 12 :xx shown as 00:xx in SimpleDateFormat. 格式 ("hh:mm:ss")

java - 如何为GridView列表添加ViewHolder?

android - 使用 Phonegap for android 的应用程序图标

xml - 如何在xml中使路径位置动态化

xml - 由于 XML,R 不会停止获取内存/RAM