android textview click on a link

十年热恋 提交于 2019-12-11 12:17:44

问题


If I have a textview with spanned text obtained from Html.fromHtml(source), how to make the textview to react when I click on a link? In my textview, link is something like "click here" and this text is a link, it's not a direct link like www.google.com.


回答1:


The best way I used and it always worked for me

 android:autoLink="web"

Hope this will help you all.

Thanks, rohit




回答2:


Butter to use Linkify
Refer Android Text Links Using Linkify




回答3:


I guess you want to handle span click event by yourself.
There two ways for this:
1)Create new class extends URLSpan
2)Create new class extends LinkMovementMethod

Please see below url, may be help you.
https://stackoverflow.com/a/16182500/596555



来源:https://stackoverflow.com/questions/5389188/android-textview-click-on-a-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!