Error! using CDATA in strings.xml resource Android

情到浓时终转凉″ 提交于 2019-12-05 00:02:17

Apostrophes (') must be escaped using \. Try using \' instead of ' throughout the content of your String.

Also, you'll need to escape " in the following part with \":

“Every  nation  that  has  struggled  to  build  democracy  has  found  that  success
depends on leaders  who believe government exists to  serve people, not the
other  way  around.”

String Formatting and Styling says

Escaping apostrophes and quotes

If you have an apostrophe or a quote in your string, you must either escape it or enclose the whole string in the other type of enclosing quotes. For example, here are some stings that do and don't work:

<string name="good_example">"This'll work"</string>
<string name="good_example_2">This\'ll also work</string>
<string name="bad_example">This doesn't work</string>
<string name="bad_example_2">XML encodings don&apos;t work</string>

It looks like bad_example_2 describes your problem. Your best bet is to mimic good_example_2 by replacing both ' and " with \' and \" respectively as suggested by Raghav Sood.

Use &#39; instead of apostrophe. The effect of character is in case of HTML output (I guess it is html) equal. So &#39; will be displayed as '.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!