简体   繁体   English

如何在android中的string.xml中添加带有多个段落的长文本

[英]How to add a long text with many paragraphs in string.xml in android

When I added many paragraphs between 当我在之间添加许多段落时

<string name="bbb"> ...... </string>

it showed me following error. 它向我显示了以下错误。

[2014-12-22 14:54:55 - Inspiration] Her father rescued her from the heartless husband  and she was back her to the 
[2014-12-22 14:54:55 - Inspiration] G:\adt-bundle-windows-x86_64-20140702\workspace\Inspiration\res\layout\activity_women.xml:11: error: Error: No resource found that matches the given name (at 'text' with value '@string/Women1').

Try this 试试这个

 <string name="Your string name" > This is your string.

       This is the second line of your string.\n\n Third line of your string.</string>

This will result in the following on your TextView: 这将导致TextView上的以下内容:

This is your string.

This is the second line of your string.

Third line of your string.

You can add the long string to /res/values/strings.xml, as it appears you've done. 您可以将长字符串添加到/res/values/strings.xml,就像您看到的那样。

You can separate paragraphs with the \\n . 您可以使用\\n分隔段落。

You will need to use Unicode codes for special characters like backslash, etc.. See this answer . 您需要对反斜杠等特殊字符使用Unicode代码。请参阅this answer

Yes, was just going to add what's in the other answer: The other trick is to use the CDATA trick: 是的,只是要添加其他答案中的内容:另一个技巧是使用CDATA技巧:

<![CDATA[Foo Bar <a href="foo?id=%s">baz</a> is cool]]>

See this answer for more on that . 有关详细信息,请参阅此答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM