Make Links In TextView Clickable
Posted by blogmeister on
May 28, 2012
There will be cases where we may want our text in strings.xml intact without adding HTML tags in order for hyperlinks to be shown as underlined and colored blue. Just like my experience.
I did not want the text in my strings.xml file for this certain variable to have HTML formatted tags within it.
Let us have an example:
|
1 |
<string name="test">This is a hyperlink, so <a href="http://www.google.com">click me</a>.</string> |
To make the hyperlink in the TextView to be linkable, simply call this programmatically:
|
1 |
textview.setMovementMethod(LinkMovementMethod.getInstance()); |
That is all. Do not add the attribute android:autoLink=”web” in your layout XML, or else it won’t work.
Donations appreciated. Every little $ helps. Or click Google +1.










2 Responses to “Make Links In TextView Clickable”
I’m doing the same in my app. I have two links on my login screen (one for create new account, the other for forgot password). Every once in a while, the first link loses it’s “link style” (blue text with underline). Have you ever run into this issue?
By Rich on Aug 21, 2012
@rich: i have not come across this scenario yet. sorry
By admin on Aug 21, 2012