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.


[wpedon id="7041" align="center"]

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.