我从Web服务返回了HTML字符串。样本字符串将是:
我想在标签字段中显示HTML字符串。
我已将字符串<b>
,<br/>
替换为</n>
。很好。
我想将<strong>
,</strong>
上的字符串设置为粗体。
答案 0 :(得分:0)
在标签字段中不起作用,因此如果要根据HTML标签显示,则需要使用浏览器字段,如
String str="<html><head><style type=\"text/css\">a {color:OLIVE;}</style></head><body style=background-image:url('local:///background.png');background-repeat:no-repeat; width:100%;height:100%;> <font size=3 color=olive><b>About Us</b></font> <font size=2>"what the string do you want to show hear you can paste"</body></html>";
browser_field.displayContent(str,"");
答案 1 :(得分:0)
如果您想将所有文字设为粗体,请使用:
yourLabelField.setFont(getFont().derive(Font.BOLD, getFont().getHeight()));
如果您只想要文本的一部分,则必须使用RichTextField:
http://www.blackberry.com/developers/docs/3.7api/net/rim/device/api/ui/component/RichTextField.html