android: Apostrophe not preceded by \ 错误

来源:互联网 发布:网路和网络 编辑:程序博客网 时间:2024/06/11 10:28

今天在生成资源的时候,Android爆出了一个错误:


Apostrophe not preceded by \

后来知道,这是因为字符串里有单引号字符 ' ,这个字符需要转义一下下。


例如原来字符串是:I'am shuaiguo!

需要替换为: I\'am shuaiguo!