<string name="no_city"><font color='#FF0000'><b>Please select your location under Preferences in the menu</b></font> </string>
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.contents);
this.setContentView(R.layout.contents);
ChangeLog cl = new ChangeLog(this);
if (cl.firstRun())
cl.getFullLogDialog().show();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
TextView text1 = (TextView)findViewById(R.id.textview1);
Resources res = getResources();
String text = String.format(res.getString(R.string.no_city));
CharSequence styledText = Html.fromHtml(text);
text1.setText(prefs.getString("listPref",res.getString(R.string.no_city)));
我试图更改no_city字符串文本的颜色。我的方式是将字符串输入顶部,下面是java。 Ihav尝试了十六进制和颜色名称,但都没有工作。我在Google的开发者网站上找到了关于如何引用这些更改的信息,它编译得很好,但文本仍然是白色的。如果没有从列表中选择任何内容,我将使用具有列表首选项的字符串作为默认显示的字符串。当用户进行选择时,文本需要为白色,所以我无法更改xml或java文件中的整个文本视图颜色。我有一种感觉,我缺少一些小东西,或者我忽略了某些东西,但我无法追踪它。变迁字符串文本颜色