0

In my strings.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="informations_links">Read these <b><a href=\"com.android.mobile://ReaderActivity\">general informations</a></b> and <a href=\"com.android.mobile://ReaderActivity\">this main note</a> from this box.</string>
</resources>

Then I use it like that:

mTextView.setText(Html.fromHtml(getString(R.string.informations_links)));

It doesn't work. My text is not formatted.

But if I write directly this and it works (it's the same string):

mTextView.setText(Html.fromHtml("Read these <b><a href=\"com.android.mobile://ReaderActivity\">general informations</a></b> and <a href=\"com.android.mobile://ReaderActivity\">this main note</a> from this box."));

So, what is the best writing in my strings.xml ?

1 Answer 1

1

You have to wrap the string content into <Data></Data>

<string name="my_string"><Data><![CDATA[<p>This is a paragraph!</p>]]> </Data></string>

android string.xml reading html tags problem

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

Comments

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.