Skip to content
Advertisement

Make HTML anchor links start a new activity in Android Java

I have a String that contains HTML tags which I display in a TextView

JavaScript

Now I want those links to be clickable, and not just clickable, but to startup an Activity when clicked. The href attributes have numbers which I want to pass as a parameter to my Intent to start my Activity.

I use JSoup to extract the values of the href like this:

JavaScript

So I was hoping I can get a ClickEventListener on the links and start the activity like this:

JavaScript

I know element is not a ViewGroup so it can’t be done like my code shows, but is there any possible way of achieving this?

Advertisement

Answer

Search and I got an answer from here

JavaScript

And then the makeLinkClickable method to handle the links

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement