random "text" here

Quotation marks not shown on the display

In my string XML file, I have a string like this:

<string name="infoHeader">random "text" here</string>

But it only displays as

random text here

on the phone’s display, that is, without quotes.

I read about it through Google and tried several HTML styles:

<string name="infoHeader">random &quot;text&quot; here</string>

And then used:

String hej = res.getString(R.string.infoHeader);     
Spanned marked_up = Html.fromHtml(hej);
((TextView)findViewById(R.id.infoHeader)).setText(marked_up, BufferType.SPANNABLE);

But that still doesn't work. I tried another HTML code, for example &lt;i>text&lt;/i>, and this works fine. What's wrong?

+3
source share
3 answers

Try the following:

<string name="infoHeader">random \"text\" here</string>
+9
source

Try the following:

  Value:  \"Hello\" 

in the resource window or

<string name="hello">\&quot;Hello\&quot;</string>

in xml file

+3
source

I'm not sure what is going on, but I tried a few more ways to avoid.

This worked for me:

<string name="hello">Hello \"World,\" ActivityHello!</string>
0
source

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


All Articles