如何在TextView中点击正常链接? [英] How to make normal links in TextView clickable?
问题描述
在我的Android应用程序,我有一个的TextView
。该文本可以包含链接。这是一个文本的例子:
In my Android app, I have a TextView
. The text can contain links. This is an example of a text:
这只是一个测试。点击以下链接http://www.google.com访问谷歌。
请注意,该文本是不是HTML ;这将只是一个普通的文本。
Note that the text is not in HTML; it will be just a regular text.
我要像做 textView.parseLinks()
,然后在的TextView
, http://www.google.com
将是超链接,并点击打开的页面。
I want to do something like textView.parseLinks()
, then in the TextView
, http://www.google.com
will be hyper-linked and clickable to open up the page.
这可能吗?
感谢
推荐答案
尝试,包括在的TextView
定义XML文件中的以下内容:
Try and include the following in the TextView
definition in XML file:
<TextView
...
android:autoLink="web"/>
的<一个该文档href="http://developer.android.com/reference/android/widget/TextView.html#attr_android:autoLink">android:autoLink说:
控制是否如URL和电子邮件地址的链接将被自动发现并转换为可点击的链接
Controls whether links such as urls and email addresses are automatically found and converted to clickable links
因此,对于自动查找链接,上面可能会有帮助。试试吧。
So for automatically finding links, the above may help. Try and see.
这篇关于如何在TextView中点击正常链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!