......

How to add long text with many paragraphs in string.xml file in android

When I added a lot of paragraphs between

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

he showed me the 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'). 
+6
source share
3 answers

try it

  <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 in your TextView:

 This is your string. This is the second line of your string. Third line of your string. 
+5
source

You can add a long line to /res/values/strings.xml as it seems you did.

You can separate paragraphs with \n .

You will need to use Unicode codes for special characters such as backslashes, etc. See this answer .

Yes, I was just about to add that in another answer: Another trick is to use the CDATA trick:

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

See more details.

+1
source

Surround your text with CDATA

Take a look at w3schools

CDATA Character Data - (Unparsed)

+1
source

Source: https://habr.com/ru/post/980026/


All Articles