如何使TextView的BOLD特定文本 [英] how to make a specific text on TextView BOLD

查看:136
本文介绍了如何使TextView的BOLD特定文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何使TextView的一个特定的文字变为粗体。

I don't know how to make a specific text on TextView become BOLD.

其像这样

txtResult.setText(id+" "+name);

我要的输出是这样的:

I want the output to be like this:

1111 尼尔

ID 名称是我所检索到数据库中的值的变量,我想使 ID 大胆,但只有 ID ,以便名称将没有受到影响,我不知道如何做到这一点。

id and name are variables that I have retrieved the value from database, and I want to make the id to bold, but only the id so the name will not affected, I have no idea how to do this.

推荐答案

刚刚建立你的字符串中的HTML和设置:

Just build your String in HTML and set it:

String sourceString = "<b>" + id + "</b> " + name; 
mytextview.setText(Html.fromHtml(sourceString));

这篇关于如何使TextView的BOLD特定文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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