1、手动创建(不建议):
1 TextView tv = new TextView(this); 2 3 tv.setContent("你好"); 4 5 setContentView(tv);
2、建议使用单位:
1 TextView tv = (TextView)findViewById(R.id.tv); 2 3 tv.setText(HTML.fromHtml("欢迎您,<font color=red>Katherine</font>"));
3.2.2、SpannableStringBuilder类:
1 TextView tv = (TextView)findViewById(R.id.tv); 2 3 String str = "欢迎您,Katherine"; 4 5 SpannableStringBuilder style = new SpannableStringBuilder(str); 6 7 style.setSpan(new ForegroundColorSpan(Color.RED), 4, 13, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); 8 9 tv.setText(style);
原文:http://www.cnblogs.com/hdwons/p/android_textview.html