0

我正在使用以下代码

LayoutInflater inflater = (LayoutInflater) getActivity()
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View innerView = inflater.inflate(R.layout.ac_image_list, null);

TextView tv = (TextView)  innerView.findViewById(R.id.tv_sorting);
tv.setText(Html.fromHtml(getString(R.string.sort_by_num_messages)));

字符串 sort_by_num_messages 定义为

<string name="sort_by_likes"><![CDATA[Sort by <b>Messages</b>]]></string>

问题是显示如下:Sort by <b>Messages</b>

该代码正在其他活动中工作,我没有使用 LayoutInflator。该代码在用作 Tab 的 SherlockFragment 中使用。

4

2 回答 2

2

摆脱 CDATA 的东西,然后像这样引用字符串:

<string name="sort_by_likes">"Sort by <b>Messages</b>"</string>
于 2013-10-18T11:36:17.480 回答
1

这正是您的代码应该显示的内容。
里面的任何东西<![CDATA[ ... ]]>都不应该被解析,并且应该在你写的时候完全显示出来。

您可以在这里阅读更多内容: 什么是 html 中的 CDATA?

于 2013-10-18T11:24:35.303 回答