为什么文本不显示为我在xml中编写的?

时间:2018-07-11 08:25:43

标签: android xml string listview checkbox

为什么我写的文字不是粗体和斜体? 这是我的值字符串xml代码:

 <string name="fragrance"> <b>FirstItem</b> \n<i>Description</i> </string>

enter image description here

1 个答案:

答案 0 :(得分:1)

您必须通过以下方式进行设置:

Spanned htmlString = Html.fromHtml(getString(R.string.fragrance));
textView.setText(htmlString);