安卓:让人物大胆XML [英] Android:Make characters bold in xml

查看:115
本文介绍了安卓:让人物大胆XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写这条线在strings.xml中:

I write this line in the strings.xml:

<string name="Help">This<b>Caaaaaa</b> on the spot.</string>

℃之间的字符; B&GT; 标记不会成为大胆。我在做什么错误? PS:我只是想做出一些部分的字符串(如Caaaaa以上)粗体

But the characters between the <b> tag don't become bold. What am I doing incorrectly? PS:I just wanna make some part in the string (like "Caaaaa" above) bold.

推荐答案

当你设置一些小部件添加到该字符串文本使用下面的code:

When you set the text of some widget to this string use the following code:

在strings.xml中使用添加乌尔字符串:

In strings.xml use this to add ur string:

<string name="Help">
    <![CDATA[
    This <b>Caaaaaa</b> on the spot.
    ]]>
    </string>

在你的活动

yourWidget.setText(Html.fromHtml(getString(R.string.Help)));

这篇关于安卓:让人物大胆XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆