簡體   English   中英

如何在android中的string.xml中添加帶有多個段落的長文本

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

當我在之間添加許多段落時

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

試試這個

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

您可以將長字符串添加到/res/values/strings.xml,就像您看到的那樣。

您可以使用\\n分隔段落。

您需要對反斜杠等特殊字符使用Unicode代碼。請參閱this answer

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

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

有關詳細信息,請參閱此答案

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM