4

Styling with HTML markup, it's not work in strings.xml and I don't know, why.

<string name="autores">This aplication is developed by <i>Charles</i></string>

And it set the phrase without italic way in the word Charles. What could it be the problem?

Thanks a lot

marioerro
  • 61
  • 1
  • 13

2 Answers2

8

Solution:

You can use CDATASection.

Example:

<string name="autores">
<![CDATA[
This application is developed by <i>Charles</i>
]]>
</string>

and

dialog.setMessage(Html.fromHtml(this.getString(R.string.autores)));

Reference:

CDATASection

I hope it will be helpful !!

Mehul Joisar
  • 15,348
  • 6
  • 48
  • 57
0

The strings.xml file is not meant to be used this way. Use SpannableStrings programmatically instead. For example: Highlighting Text Color using Html.fromHtml() in Android?

Community
  • 1
  • 1
Piovezan
  • 3,215
  • 1
  • 28
  • 45
  • Ok, but I want to set in a AlertDialog.Builder dialog.setMessage(Html.fromHtml(this.getString(R.string.phrase))); – marioerro Jun 06 '13 at 19:52
  • IT's not work!! dialog.setMessage(Html.fromHtml(this.getString(R.string.phrase))); But if I write a normal string, that is working!! Why? Isn't it possible to do it with a text from strings.xml? – marioerro Jun 06 '13 at 20:16