Html 标签在字符串资源中不起作用
Html tags won't work in string resource
我得到了这个字符串资源:
<string name="about_app_text"><b>%1$s</b> some text.\n\n
<b>%2$s, text</b>, more text.</string>
<b>
标签内的文本未变为粗体。这是为什么?
你可以试试这个
YourTextview.setText(Html.fromHtml(getResources().getString(R.string. about_app_text)));
字符串资源:
<string name="about_app_text"><![CDATA[<b>%1$s</b> some text.\n\n
<b>%2$s, text</b>, more text.]]></string>
<string name="about_app_text"><![CDATA[<b>%1$s</b> some text.\n\n
<b>%2$s, text</b>, more text.]]></string>
然后解析为Spannable
Spanned spanned = Html.fromHtml(getString(R.string.about_app_text));
textView.setText(Spanned);
我得到了这个字符串资源:
<string name="about_app_text"><b>%1$s</b> some text.\n\n
<b>%2$s, text</b>, more text.</string>
<b>
标签内的文本未变为粗体。这是为什么?
你可以试试这个
YourTextview.setText(Html.fromHtml(getResources().getString(R.string. about_app_text)));
字符串资源:
<string name="about_app_text"><![CDATA[<b>%1$s</b> some text.\n\n
<b>%2$s, text</b>, more text.]]></string>
<string name="about_app_text"><![CDATA[<b>%1$s</b> some text.\n\n
<b>%2$s, text</b>, more text.]]></string>
然后解析为Spannable
Spanned spanned = Html.fromHtml(getString(R.string.about_app_text));
textView.setText(Spanned);