Simon Simon - 4 months ago 26
Android Question

Use string replace to change text color of URL link

What I mean is, is it possible to change the text URL link to the color green in a single string?

For example when I have a string which includes muliple URLs like below example. (Part 1) is it possible to set the text color of "" to green using string replace so it gets like in Part2?

Part 1:

<a class="postlink" href=""><br/></a><br/>Mirror:<br/><a class="postlink" href=""><br/></a>

Part 2:

<a class="postlink" href=""><font color='#1AB053'></font><br/></a>


You can see this solution to enable links in a TextView from a HTML content and, to set link colors you could set the android:textColorLink attribute in XML layout to specify the links' color.

If you want only convert text URLs to links, is not necessary Java code. You can simply add this in your TextView: