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

时间:2014-12-22 09:48:53

标签: android xml android-layout android-activity

当我在

之间添加许多段落时
<string name="bbb"> ...... </string>

它向我显示了以下错误。

[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').

2 个答案:

答案 0 :(得分:5)

试试这个

 <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>

这将导致TextView上的以下内容:

This is your string.

This is the second line of your string.

Third line of your string.

答案 1 :(得分:1)

您可以将长字符串添加到/res/values/strings.xml,就像您已经完成的那样。

您可以使用\n

分隔段落

您需要对反斜杠等特殊字符使用Unicode代码。请参阅this answer

是的,只是要添加其他答案中的内容:另一个技巧是使用CDATA技巧:

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

请参阅this answer for more on that