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

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

1 Comment

No need to use CDATA, just replace < with &lt;
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?

2 Comments

Ok, but I want to set in a AlertDialog.Builder dialog.setMessage(Html.fromHtml(this.getString(R.string.phrase)));
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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.