自动链接属性不同的文本与实际的链接(setAutoLinkMask) [英] Auto link property different text with the actual linking (setAutoLinkMask)

查看:733
本文介绍了自动链接属性不同的文本与实际的链接(setAutoLinkMask)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如

TextView tv =(TextView)this.findViewById(R.id.tv);
tv.setAutoLinkMask(Linkify.ALL);
tv.setText("visit website, http://www.google.com");

pressing在 http://www.google.com 会带我去的 http://www.google.com
我想做的事情是这样

pressing on http://www.google.com will take me to http://www.google.com. The thing I want to do is like this

TextView tv =(TextView)this.findViewById(R.id.tv);
tv.setAutoLinkMask(Linkify.ALL);
tv.setText("visit this website");

和在本我要带我去 http://www.google.com

我怎样才能做到这一点? (有没有可能呢?)

How can I do this ? (is it possible at all ?)

推荐答案

从API演示,

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());

这篇关于自动链接属性不同的文本与实际的链接(setAutoLinkMask)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆