android textview click on a link

2019-08-08 02:36发布

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.

3条回答
Lonely孤独者°
2楼-- · 2019-08-08 03:25

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

查看更多
3楼-- · 2019-08-08 03:32
聊天终结者
4楼-- · 2019-08-08 03:41

The best way I used and it always worked for me

 android:autoLink="web"

Hope this will help you all.

Thanks, rohit

查看更多
登录 后发表回答