关于TextView中怎么添加超链接的问题
来源:互联网 发布:测试端口开放 编辑:程序博客网 时间:2024/06/05 09:08
在TextView中使用超级连接有几种方式:
1.在属性中设置:
< TextView
android:id="@+id/testweb"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android: //是将文本的web网址解释成超链接
android:text="@string/link_text_auto"
/>
autoLink:一共有几种值:web,phone,map,email.all.none.
分别是url连接。电话号码提取拨号,地图地址。电子邮件,全部解释就是能支持的超级连接全部起作用,
none就是默认情况,没有超链接。
2.使用html文本:
例如:
< ?xml version="1.0" encoding="utf-8"?>
< resources>
< string name="link_text_manual">
a < a href="http://www.google.com">link< /a> specified
via an < a> tag. Use a \"tel:\" URL
to < a href="tel:4155551212">dial a phone number< /a>.
< /string>
< /resources>
< TextView
android:id="@+id/testemail"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/link_text_manual"
/>
3.在java代码中添加超级连接:
TextView t = (TextView) findViewById(R.id.text3);
t.setText(
Html.fromHtml(
"< b>text3:< /b> Text with a " +
"< a href=\"http://www.google.com\">link< /a> " +
"created in the Java source code using HTML."));
t.setMovementMethod(LinkMovementMethod.getInstance());
4.使用:SpannableString
SpannableString ss = new SpannableString("Click here to dial the phone.");
ss.setSpan(new StyleSpan(Typeface.BOLD), 0, 6, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
ss.setSpan(new URLSpan("tel:4155551212"), 13, 17, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
TextView t = (TextView) findViewById(R.id.text4);
t.setText(ss);
t.setMovementMethod(LinkMovementMethod.getInstance());
转载自:http://blog.sina.com.cn/s/blog_68119c8b0100vdam.html
- 关于TextView中怎么添加超链接的问题
- Android 中TextView 添加超链接
- 在TextView中添加超链接
- TextView的超链接问题
- TextView中添加超链接的四种方式
- Android在文本中添加超链接 (TextView)
- Android在文本中添加超链接 (TextView)
- textView 添加超链接
- textview 添加超链接
- textview添加超链接
- textview添加超链接
- 设置TextView中文字的超链接
- android TextView中超链接的事件捕捉
- TextView中超链接功能的实现
- TextView中设置超链接
- android中怎么动态添加TextView控件
- Android开发:TextView添加超链接的简便方法
- 给TextView添加超链接的四种方式
- Android开发之EditText属性详解
- 自定义进度条
- android webview 学习
- 欢迎使用CSDN-markdown编辑器
- python 机器学习的开发环境搭建(numpy,scipy,matplotlib)
- 关于TextView中怎么添加超链接的问题
- Android TextView中文字设置超链接、颜色、字体
- android中用Spannable在TextView中设置超链接、颜色、字体
- android中dip、dp、px、sp和屏幕密度
- Java开发was not found on the java.library.path解决方法
- android OutOfMemoryError
- [unreal4入门系列之十五] UE4中的动态数组:TArray容器
- 解决ScrollView下嵌套ListView、GridView显示不全的问题
- 获取Android手机总内存和可用内存