Android 字符串 HTML 失败
Android string with HTML failed
在我的 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>
那我就这样用:
mTextView.setText(Html.fromHtml(getString(R.string.informations_links)));
没用。我的文本没有格式化。
但是如果我直接写这个并且它有效(它是 相同的 字符串):
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."));
那么,我的 strings.xml 中最好的写作是什么?
你必须将字符串内容包装成<Data></Data>
<string name="my_string"><Data><![CDATA[<p>This is a paragraph!</p>]]> </Data></string>
android string.xml reading html tags problem
在我的 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>
那我就这样用:
mTextView.setText(Html.fromHtml(getString(R.string.informations_links)));
没用。我的文本没有格式化。
但是如果我直接写这个并且它有效(它是 相同的 字符串):
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."));
那么,我的 strings.xml 中最好的写作是什么?
你必须将字符串内容包装成<Data></Data>
<string name="my_string"><Data><![CDATA[<p>This is a paragraph!</p>]]> </Data></string>
android string.xml reading html tags problem