【问题标题】:Why text does not show as I wrote it in xml? [duplicate]为什么我在 xml 中写的文本没有显示? [复制]
【发布时间】:2018-12-19 05:02:23
【问题描述】:

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

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

【问题讨论】:

    标签: android xml string listview checkbox


    【解决方案1】:

    你必须这样设置:

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

    【讨论】:

    • 我有一个 MyItem 类。它只需要字符串,我不能将 html 字符串传递给它。 myitems.add(new MyItem(getString(R.string.fragrance),false));
    • 好的,你可以将它作为字符串值存储在 MyItem 中,但是你必须接下来使用它作为 spanned 将它添加到 textview。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-06
    • 2021-04-04
    • 1970-01-01
    • 1970-01-01
    • 2011-04-03
    相关资源
    最近更新 更多