Android使文本视图中的超链接可点击

Android使文本视图中的超链接可点击,android,hyperlink,textview,linkify,Android,Hyperlink,Textview,Linkify,我从服务器上得到一些HTML,并显示在文本视图中。HTML有一些超链接。我希望当用户单击某个超链接时,它会在设备浏览器中打开该链接的url,但它不工作。我已经阅读了关于Linkify和使用以下内容: TextView articleDescription = (TextView)findViewById(R.id.articledescription); articleDescription.setText(Html.fromHtml(articleInfo.getArticle_body())

我从服务器上得到一些HTML,并显示在文本视图中。HTML有一些超链接。我希望当用户单击某个超链接时,它会在设备浏览器中打开该链接的url,但它不工作。我已经阅读了关于Linkify和使用以下内容:

TextView articleDescription = (TextView)findViewById(R.id.articledescription);
articleDescription.setText(Html.fromHtml(articleInfo.getArticle_body()));
Linkify.addLinks(articleDescription, Linkify.WEB_URLS);
但它太不起作用了。有什么想法吗

抱歉,伙计们,事实上我最近注意到超链接是相对于服务器的,所以我认为这就是为什么没有触发浏览器意图的原因。我有示例HTML文本:

<p><span style="font-family: Helvetica,sans-serif;"><span style="font-size: small;">Since I began reporting for It&rsquo;s Relevant in June, I have come across some amazing people living and working in Stamford. Over the past 6 months, I have had the opportunity to share their stories and report on issues affecting the city. Here are some of my favorite pieces from     2011:</span></span></p> <p><br /><a href="/content/7298/Bakers_Keep_Up_With_The_Kardashians_?ref=qmf10j"><span style="color: #000080;"><span style="font-family: Helvetica,sans-serif;"><span style="font-size: small;">Bakers Keep up with the Kardashians</span></span></span></a></p> <p><span style="font-family: Helvetica,sans-serif;"><span style="font-size: small;">This story combines two of my favorite things, the Kardashian sister&rsquo;s and cake! Deb and Dina are so talented and it was great to see them at work. </span></span></p> <p><br /><a href="www.itsrelevant.com/content/7508/Yankees_GM_Set_To_Jump_Off_Building?ref=qmf10j"><span style="color: #000080;"><span style="font-family: Helvetica,sans-serif;"><span style="font-size: small;">Yankees GM Set to Jump Off Building</span></span></span></a></p> <p><span style="font-family: Helvetica,sans-serif;"><span style="font-size: small;">Never in my life did I think I would interview the General Manager of the Yankees, let alone on the rooftop of a 22-story building!</span></span></p> <p><a href="/content/6782/Fashion_Show_Features_Cancer_Survivors?ref=0yk17d"><br /><span style="color: #000080;"><span style="font-family: Helvetica,sans-serif;"><span style="font-size: small;">Breast Cancer Fashion Show</span></span></span><span style="color: #000000;"><span style="font-family: Helvetica,sans-serif;"><span style="font-size: small;"> </span></span></span></a></p> <p><span style="font-family: Helvetica,sans-serif;"><span style="font-size: small;">These women are truly amazing! So many people are affected by cancer and the Paint the Town Pink committee spent October bringing awareness to the disease. </span></span></p> <p><br /><a href="/content/5275/Downed_Trees_Remain_Problem?ref=qmf10j"><span style="color: #0000ff;"><span style="font-family: Helvetica,sans-serif;"><span style="font-size: small;">Downed Trees Remain Problem </span></span></span></a></p> 
自从我开始为It部门做报告以来;在六月,我遇到了一些生活和工作在斯坦福德的了不起的人。在过去的6个月里,我有机会分享他们的故事,并就影响城市的问题进行报道。以下是我2011年最喜欢的作品:


这个故事结合了我最喜欢的两件事,卡戴珊姐姐&rsquo;巧克力和蛋糕!黛布和迪娜很有天赋,看到他们在工作真是太好了


我一辈子都没想到我会采访洋基队的总经理,更不用说在22层楼的屋顶上了

这些女人真是太棒了!如此多的人受到癌症的影响,镇粉红委员会在10月份用油漆使人们认识到这种疾病



现在有什么建议该怎么做哪类数据?或者某种正则表达式,这样我就可以替换服务器绝对路径的相对路径了?

看看这个。它可能会有帮助

  TextView tv=new TextView(this);
    tv.setLayoutParams(lparams);
    webview =new WebView(this);
    webview.setLayoutParams(lparams);
    tv.setText(Html.fromHtml("<a href='http://www.google.com'>www.google.com</a>"));
    tv.setClickable(true);
    tv.setMovementMethod(LinkMovementMethod.getInstance());
    URLSpan[] urlSpans = tv.getUrls();
    for ( URLSpan urlSpan : urlSpans )  
    {  
        webview.loadUrl( urlSpan.getURL() ); 
    }  
TextView电视=新的TextView(本);
设置布局参数(lparams);
webview=新的webview(此);
setLayoutParams(lparams);
tv.setText(Html.fromHtml(“”);
tv.setClickable(真);
setMovementMethod(LinkMovementMethod.getInstance());
URLSpan[]urlSpans=tv.getUrls();
用于(URLSpan URLSpan:URLSpan)
{  
loadUrl(urlSpan.getURL());
}  

看看这个链接

试着这样做:

TextView articleDescription = (TextView)findViewById(R.id.articledescription);
articleDescription.setMovementMethod(LinkMovementMethod.getInstance());
articleDescription.setText(Html.fromHtml(articleInfo.getArticle_body()));
这个怎么样,

TextView t2 = (TextView) findViewById(R.id.*example*);
t2.setMovementMethod(LinkMovementMethod.getInstance());