如何在 TextView BOLD 上制作特定文本 [英] how to make a specific text on TextView BOLD

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

问题描述

我不知道如何使 TextView 上的特定文本变为 BOLD.

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

是这样的

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

我希望输出是这样的:

1111尼尔

idname 是我从数据库中检索值的变量,我想将 id 设置为粗体,但仅id 所以 name 不会受到影响,我不知道该怎么做.

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天全站免登陆