简体   繁体   English

如何拦截单击TextView中的链接?

[英]How to intercept click on link in TextView?

I have TextView and it contain HTML with tags. 我有TextView,它包含带标签的HTML。 I need to intercept user's clicks on this links, take value of "href" parameter, check it and open my activity if it local link or open browser if it link to another site. 我需要拦截用户对此链接的点击,获取“href”参数的值,检查它并打开我的活动,如果它是本地链接或打开浏览器,如果它链接到另一个网站。

I've try to search and find that , but I can't understand how to use it in my case. 我试着搜索并找到 ,但我无法理解如何在我的情况下使用它。

Please, help. 请帮忙。

There's this method: https://stackoverflow.com/a/3452944/1799219 有这种方法: https//stackoverflow.com/a/3452944/1799219

All it's really doing is passing the link to your own activity (as links are normally passed to other activities) and then you extract the URL. 所有它真正做的是将链接传递给您自己的活动(因为链接通常传递给其他活动),然后您提取URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM