我想知道是否可以在Java中更改字符串中的文本颜色?
我的警告对话框中有一些文字,基本上我喜欢的是所有粗体文字,我希望这些文字的颜色是红色,而文本的其余部分是黑色。这是可能的,如果可以的话,如何实施?
alertDialog.setMessage(Html.fromHtml("<b>Number of Human Players Required:</b>" + "<br/><br/>" +
" 2" + "<br/><br/>" +
"<b>Objective Of The Game:</b>" + "<br/><br/>" +
"The objective of Tic Tac Toe is to get three in a row either in a vertical line, " +
"horizontal line or diagonal line."
)
谢谢,
答案 0 :(得分:2)
您可以这样做:
ext { archLifecycleVersion = '1.1.0'}
dependencies {
implementation "android.arch.lifecycle:extensions:$rootProject.archLifecycleVersion"
annotationProcessor "android.arch.lifecycle:compiler:$rootProject.archLifecycleVersion"}