Enabling links inside HTML or TextView [ANDROID DEVELOPMENT]

HTML(1)In the last post, I showed you guys how to show HTML inside the TextView.

But the thing was that if you had links in your HTML then they wouldn’t work. That is the links would show like they should but if you clicked on the links nothing would happen.

That is because they aren’t enabled yet.

You can enable the links inside the HTML or the TextView for that matter by just adding a couple of lines of code.

Just make sure that you are passing the text to the TextView from a string resource. And then add the following code to the OnCreate Method of your JAVA file of the Activity:

TextView newtext = (TextView) findViewById(R.id.textView1);

So that the JAVA file looks like this:links in html or textview

That’s it! That’s how you enable the links inside the TextView.

Hope you found it useful.

Leave your questions in the Comments Section below.


Hey! I am a Physics Major at the University of Delhi. I dream of being a Theoretical Physicist one day. I love playing Guitar in my free time. I can speak English, Hindi and a little French. I am also a Web Development Enthusiast and a hardcore Gamer.

Leave a Reply

Your email address will not be published. Required fields are marked *