我的Android进阶之旅------>Android字符串资源中的单引號问题error: Apostrophe not preceded by 的解决的方法

刚刚在string字符串资源文件里,写了一个单引號。报错了,错误代码例如以下

error: Apostrophe not preceded by  (in OuyangPeng's blog )


资源文件例如以下:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="ouyang">OuyangPeng's blog </string>
    <string name="blog"> http://blog.csdn.net/ouyang_peng</string>
</resources>

解决方法有两种。例如以下所看到的:

第一种方法:使用双引號将单引號的字符串资源括起来,例如以下所看到的:

<string name="ouyang">"OuyangPeng's blog" </string>

另外一种方法: ’ 号之前要加 进行转义 ,这样做是为了避免歧义。例如以下所看到的:

<string name="ouyang">OuyangPeng's blog </string>


參考了之前的一篇文章:《我的Android进阶之旅------>报 error: Apostrophe not preceded by 的错误解决的方法

(地址:http://blog.csdn.net/ouyang_peng/article/details/16939225)



                            ====================================================================================

  作者:欧阳鹏  欢迎转载,与人分享是进步的源泉!

  转载请保留原文地址http://blog.csdn.net/ouyang_peng

====================================================================================

 




原文地址:https://www.cnblogs.com/yfceshi/p/7289486.html