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.


PhD researcher at Friedrich-Schiller University Jena, Germany. I'm a physicist specializing in computational material science. I write efficient codes for simulating light-matter interactions at atomic scales. I like to develop Physics, DFT and Machine Learning related apps and softwares from time to time. Can code in most of the popular languages. Like to share my knowledge in Physics and applications using this Blog and a YouTube channel.
[wpedon id="7041" align="center"]

Leave a Reply

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