请在Android中的超链接的TextView请在、超链接、Android、TextView

2023-09-04 04:43:24 作者:Infatuation 迷恋

我想打一个链接,如谷歌一个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));