如何在android中的R.plurals.cats文本视图中设置粗体样式的数量文本

MAR*_*RSH 1 android

我使用复数来简化我的代码。例如,我曾经有过

<string name="cat">Cat</string>
<string name="cats">Cats</string>
Run Code Online (Sandbox Code Playgroud)

使用复数而不是多个字符串,我现在有了

<plurals name="cats">
    <item quantity="<b>%d</b> one">Cat</item>
    <item quantity="<b>%d</b> other">Cats</item>
</plurals>
Run Code Online (Sandbox Code Playgroud)

但是,我曾经检索字符串以编程方式在代码中使用。例如,

    String text = context.getResources().getQuantityString(R.plurals.cats, 10);
textview.setText(Html.fromHtml(text));
Run Code Online (Sandbox Code Playgroud)

我想以粗体样式设置 10 值,但它没有设置粗体文本不包含粗体文本请帮助我如何存档此内容。

Gab*_*tti 5

使用:

  <plurals name="cats">
    <item quantity="one"><![CDATA[<b>1</b> cat</b>]]></item>
    <item quantity="other"><![CDATA[<b>%d</b> cats</b>]]></item>
  </plurals>
Run Code Online (Sandbox Code Playgroud)

和:

String text = context.getResources().getQuantityString(R.plurals.cats, 10, 2);
textview.setText(Html.fromHtml(text));
Run Code Online (Sandbox Code Playgroud)