请在Android中的超链接的TextView [英] Make a hyperlink textview in android

查看:101
本文介绍了请在Android中的超链接的TextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打一个链接,如谷歌一个TextView文本。反正有做这样的链接。 (IE)当上的字点击谷歌应该打开相应链接。任何想法是值得欢迎的。

I want to make a link for a textview text like Google. Is there anyway to make link like this. (i.e) When clicking on the word Google it should open the appropriate link. Any ideas are welcome.

推荐答案

试试这个,让我知道发生什么事。

Try this, and let me know what happen..

TextView textView =(TextView)findViewById(R.id.textView);
textView.setClickable(true);
textView.setMovementMethod(LinkMovementMethod.getInstance());
String text = "<a href='http://www.google.com'> Google </a>";
textView.setText(Html.fromHtml(text));

这篇关于请在Android中的超链接的TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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