Simon Simon - 1 year ago 71
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>

Answer Source

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:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download