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').
As already mentioned the correct way to have a space in an XML file is by using \u0020 which is the unicode character for a space.
typical string with escape sequence like '\n' can't be used, because this string has no special meaning in XML. Instead of you need to use hexadecimal escaped character: for newline or for carriage return.
A string resource provides text strings for your application with optional text styling and formatting. There are three types of resources that can provide your application with strings: String. XML resource that provides a single string.
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:
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.
You can separate paragraphs with the \n.
You will need to use Unicode codes for special characters like backslash, etc.. See this answer.
Yes, was just going to add what's in the other answer: The other trick is to use the CDATA trick:
<![CDATA[Foo Bar <a href="foo?id=%s">baz</a> is cool]]>
See this answer for more on that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With