TextView功能总结(1)
来源:互联网 发布:清风纸巾怎么样知乎 编辑:程序博客网 时间:2024/05/16 14:22
实例1:如何显示文本(URL、大小、字体、颜色)
设置字符串超链接标签
<string name="link_text"><a href="tel:13693207964">打电话</a></string>
java文件编写
public class MainActivity extends Activity {
private TextView textView1,textView2;//定义两个TextView
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView1=(TextView)this.findViewById(R.id.textView1);
textView2=(TextView)this.findViewById(R.id.textView2);//为两个TextView分配id
//添加一段html的标志
String html="<font color='red'>I love android</font><br>";//注意,标签模式<font属性>内容</font>,内容和格式的设置,<br>表示换行
html+="<font color='#0000ff'><big><i>I love android</i></big></font><p>";//<p>表示段落,<big>表示字体比周围的大一号,<i>表示斜体
html+="<big><a href='http://www.baidu.com'>百度</a></big>";//<a href='http://www.baidu.com'>百度</a>表示为“百度”设置超链接
CharSequence charSequence=Html.fromHtml(html);//表示将字符串转换成可显示的html格式文本
textView1.setText(charSequence);
textView1.setMovementMethod(LinkMovementMethod.getInstance());// 点击时产生超链接
String text="我的URL:http://www.sina.com\n";
text +="我的Email:abcd@126.com\n";
text +="我的电话:+86 010-89486389";
textView2.setText(text);
textView2.setMovementMethod(LinkMovementMethod.getInstance());
}
}
- TextView功能总结(1)
- TextView功能总结(2)
- TextView功能总结(3)
- TextView功能总结(4)
- TextView总结
- android textView常用功能
- TextView常用功能
- Android TextView 复制功能
- EditText功能总结(1)
- textView 属性总结
- TextView 文字样式总结
- android textview问题总结
- textView 属性总结
- TextView 样式总结
- textView 属性总结
- 【总结】TextView的使用
- TextView学习总结
- textview的属性总结
- Codeforces #260(Div 2) D A lot of games(字母树+树形dp)
- php $_SERVER中的SERVER_NAME 和HTTP_HOST的区别
- Visitor 访问者模式
- 黑马程序员—TreeMap练习-字母出现的次数
- POJ 3356 AGTC.
- TextView功能总结(1)
- LeetCode刷题笔录3Sum
- Python 正则表达式查找字符串中特定字符
- AAA服务器的配置
- ubuntu 14.04 搭建LAMP环境
- HDU1262 素数筛
- ORA-12519: TNS:no appropriate service handler found 解决
- 户外露营常识
- tomcat内存溢出的解决方法(java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError:)