错误:解析XML时出错:未绑定的前缀

YoK*_*aGe 1 java xml android bluetooth

我在strings.xml文件中遇到此错误:错误:解析XML时出错:未绑定的前缀

<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>
Run Code Online (Sandbox Code Playgroud)

我做错了什么?

Jas*_*son 7

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

实际上,你想要逃离标签< >周围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>