2014-05-25 56 views
2

我有一个TextView链接其他文字。我需要链接以便点击&我需要捕获点击并在我的活动中的web视图中打开链接。我跟着这个this answer。我的代码如下所示:打开TextView链接在另一个活动 - 自定义ClickableSpan

actitivity_main.xml

<TextView android:id="@+id/textlinktest" 
       android:layout_width="wrap_content" 
       android:layout_height="50dp"/> 

这是我调用它的方式:链接显示了罚款

textLinkTest.setText(Html.fromHtml("Something else <a href=\"http://www.google.com\">google</a>")); 

textLinkTest.setText(RichTextUtils.replaceAll(
      (Spanned) textLinkTest.getText(), 
      URLSpan.class, 
      new URLSpanConverter())); 

,但他们无法点击!我customeclickablespan中的onclick永远不会被调用。我试过切换android:linksClickable &也尝试了android:autoLink的不同值。但链接仍然无法点击。有什么想法吗?

回答

0

添加

textLinkTest.setMovementMethod(LinkMovementMethod.getInstance()); 

textLinkTest.setText(RichTextUtils.replaceAll((Spanned) textLinkTest.getText(), URLSpan.class, new URLSpanConverter())); 
相关问题