Android TextView 添加链接
来源:互联网 发布:淘宝店买卖平台 编辑:程序博客网 时间:2024/05/16 08:20
使用autoLink,只要用这个属性,我们textview就可以添加链接了。
当我们在代码中写成android:autoLink="all"我们就可以在textview里面写的文字中包含网址、电话、email的会自动加入连接地址。
Java代码:
package eoe.link;
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:autoLink="all"
android:text="@string/link_text_auto" />
使用一个字符串资源含直接<一个>标签来说明链接。
Java代码:
packageeoe.link;
<stringname="link_text_manual">
<b>text2:</b>Thisissomeother
text,witha<ahref="http://www.google.com">link</a>specified
viaan<a>tag.Usea\"tel:\"URL
to<ahref="tel:4155551212">dialaphonenumber</a>.
</string>
TextViewt2=(TextView)findViewById(R.id.text2);
t2.setMovementMethod(LinkMovementMethod.getInstance());
建立了文本中使用HTML代码。
Java代码:
package eoe.link;
TextView t3 = (TextView) findViewById(R.id.text3);
t3.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."));
t3.setMovementMethod(LinkMovementMethod.getInstance());
- Android TextView 添加链接
- TextView添加链接
- TextView 添加链接
- Android高亮显示TextView某个单词,添加链接
- Android---10---TextView添加链接的两种方式
- 为TextView添加链接-setMovementMethod -- Android学习笔记6-3
- TextView中添加HTTP链接
- 为TextView添加链接-setMovementMethod
- Android TextView HTML链接
- Android TextView中添加链接并在链接部分字体变色可点击
- android textView添加阴影
- Android - TextView添加图片
- Android动态添加TextView
- android TextView 添加下划线
- android:为TextView添加样式——下划线,颜色,设置链接样式及前背景色
- android:为TextView添加样式——下划线,颜色,设置链接样式及前背景色
- android:为TextView添加样式——下划线,颜色,设置链接样式及前背景色
- android:为TextView添加样式——下划线,颜色,设置链接样式及前背景色
- 30.黑马程序员-包package
- 学习组织开会
- java动态代理(JDK和cglib)
- 操作系统理论的探索: (之四)
- Windows核心编程学习笔记(3)--获得可执行文件的实例和dll文件的实例句柄
- Android TextView 添加链接
- 【Cocos2d-x】新手自学(十)分辨率自适应!一句话搞定IOS android windows!!
- ubuntu下编译vlc-android(0.0.5版本)
- zoj 1392.The Hardest Problem Ever
- levenshtein_distance(字符串相似度算法)
- 31.黑马程序员-多线程(继承Thread)
- 项目管理者对管理的总结
- C语言如何获得精确到毫秒的时间
- 强制转换带来的疑惑