Android用户界面开发(1):TextView

TextView(文本框)

TextView就是一个用来显示文本标签的控件。

/*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</font><br>";
html += "<font color='#0000ff'><big><i>I love android</i></big></font><p>";
html += "<big><a href='http://www.baidu.com'>百度</a></big>";
CharSequence charSequence = Html.fromHtml(html);
textView1.setText(charSequence);
textView1.setMovementMethod(LinkMovementMethod.getInstance());// 点击的时候产生超链接    
String text = "我的URL:http://www.sina.com\n";
text += "我的email:****** @gmail.com\n";
text += "我的电话:+ 86 137********";
textView2.setText(text);
textView2.setMovementMethod(LinkMovementMethod.getInstance());
 

 

源码下载链接:http://www.apkbus.com/android-116981-1-1.html

喜欢开源,乐意分享的大神们,欢迎加入QQ群:176507146,你值的拥有哦!

转载于:https://www.cnblogs.com/klcf0220/archive/2013/05/19/3087749.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值