我在Textview的某些部分设置文本颜色时遇到问题。在layout-xml中将文本定义为白色。当用户在游戏中选择write answer时,会触发此方法调用:
this.Question = (TextView) findViewById(R.id.layout1Question);
this.Question.setText(Html.fromHtml("<font color = 'green'>CORRECT: </font>") + this.CurrentQuestion.getFillin());在这里,我希望正确的-part显示绿色文本,而其余的应该是默认的白色。但整个文本显示为白色。我做错了什么?
谢谢你的帮助!
编辑:如果我删除第二部分,它就会起作用,因此:
this.Question.setText(Html.fromHtml("<font color = 'green'>CORRECT: </font>"));
工作正常。
发布于 2012-09-21 17:35:25
尝试将geFillin()调用移动到fromHtml参数。可能是字符串连接将Spanned字符串转换回简单字符串。
this.Question.setText(
Html.fromHtml("<font color='green'>CORRECT: </font>" + this.CurrentQuestion.getFillin()));https://stackoverflow.com/questions/12527733
复制相似问题