TextView就是一个用来显示文本标签的控件。
(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/bianchengyuyan/)代码如下:
/*TextView的设置*//* 获得TextView对象 */
textview = (TextView)this.findViewById(R.id.textview);
String string = "TextView示例!";
/* 设置文本的颜色 */
textview.setTextColor(Color.RED);
/* 设置字体大小 */
textview.setTextSize(20);
/* 设置文字背景 */
textview.setBackgroundColor(Color.BLUE);
/* 设置TextView显示的文字 */
textview.setText(string);
代码如下:
/*TextView显示网页*/textView1 = (TextView) this.findViewById(R.id.textview1);
textView2 = (TextView) this.findViewById(R.id.textview2);
// 添加一段html的标志
String html = "font color='red'I love android/fontbr";
html += "font color='#0000ff'bigiI love android/i/big/fontp";
html += "biga href='http://www.jb51.net'脚本之家/a/big";
CharSequence charSequence = Html.fromHtml(html);
textView1.setText(charSequence);
textView1.setMovementMethod(LinkMovementMethod.getInstance());// 点击的时候产生超链接
String text = "我的URL:http://www.jb51.netn";
text += "我的email:****** @gmail.comn";
text += "我的电话:+ 86 137********";
textView2.setText(text);
textView2.setMovementMethod(LinkMovementMethod.getInstance());


