如何使TextView的BOLD特定文本 [英] how to make a specific text on TextView BOLD
本文介绍了如何使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屋!
查看全文