URL的TextView的Andr​​oid的活动链接链接、TextView、URL、oid

2023-09-03 21:28:32 作者:红颜红过她i

我已获得来自web服务的动态文本和表示在一个TextView相同。有时TextView中具有URL如< A HREF =htt​​p://hello.com>你好< / A> 。我已经尝试使用下面的code设置文本。

I have getting dynamic text from a web service and showing the same in a TextView. Sometimes the TextView has url like <a href="http://hello.com">hello</a>. I have set the text using the following code.

textView.setText(Html.fromHtml(sampletext));

和还设置安卓自动链接=网络中的相应的XML包含的TextView 。现在,该链接显示正常的蓝色颜色和下划线,但我发现它只是一个死链接。什么也没有发生,如果我们试图单击它。我必须做的,使链接激活?

And also set android:autoLink="web" in the corresponding xml of that contains the TextView. Now the link is showing properly with blue color and underline, but I found the its just a dead link. Nothing is happening if we try to click it. What I have to do to make the link active?

推荐答案

这对我的作品:

<TextView
    android:text="www.hello.com"
    android:id="@+id/TextView01"
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent"
    android:autoLink="web">
</TextView>