在对话框消息中显示带有粗体字母的字符串 [英] Display string with bold letters in Dialog message
本文介绍了在对话框消息中显示带有粗体字母的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
比方说我有这个:
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
.setMessage("I want THIS word to be bold and the rest normal!")
.create().show();
有什么办法让Android将格式设置或粗体字体应用于文本字符串的一部分?
Is there any way to have Android apply formatting or bold font to parts of the text string?
推荐答案
您可以像这样在您的strings.xml中添加一个字符串:
You can add a string to your strings.xml like this:
<string name="bold_message">I want <b>THIS</b> word to be bold and the rest normal!</string>
,然后在警报对话框中使用setMessage(R.string.bold_message)
and then in your alert dialog just use setMessage(R.string.bold_message)
这篇关于在对话框消息中显示带有粗体字母的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文