Method for capturing link click events in ttextview text in Android

The ttextview in Android is very powerful. We can not only set plain text as its content, but also set the content including web address and e-mail address, and make these clicks clickable. But can we capture and control the click events of these links? Of course.

This article will introduce a super simple example of how to capture link click events in Android textview.

Key implementation

The implementation principle is to set all URLs as clickspan, and then add the control logic you want in its onclick event.

How to use

Achieve your own control

We need to add our own control logic to the onclick method of clickspan. For example, we use Aoyou browser to open the clicked link.

remind

Don't forget to set the AutoLink property of textview.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>