TextView的使用实例 Android用户界面开发之:TextView的使用实例

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

TextView的使用实例 Android用户界面开发之:TextView的使用实例

  2021-03-18 我要评论
想了解Android用户界面开发之:TextView的使用实例的相关内容吗,在本文为您仔细讲解TextView的使用实例的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点: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='//www.qb5200.com'></a></big>";
CharSequence charSequence = Html.fromHtml(html);
textView1.setText(charSequence);
textView1.setMovementMethod(LinkMovementMethod.getInstance());// 点击的时候产生超链接   
String text = "我的URL://www.qb5200.com\n";
text += "我的email:****** @gmail.com\n";
text += "我的电话:+ 86 137********";
textView2.setText(text);
textView2.setMovementMethod(LinkMovementMethod.getInstance());

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们