1

I have textview in which multiple links are shown, the text is dynamic. I have added following to textview

android:autoLink="all"
android:textColorLink="@color/selector_autolink_textcolor"

This makes all links in textview show a different color and show click color, but on click of textview all the links in textview show selected color, this confuses the user as he cannot identify what he's clicking. How can I only highlight/show press-state of a single link when pressed.

chin87
  • 498
  • 4
  • 18

1 Answers1

1

I have two approaches for you to solve this problem.

First Approach:- This one is quite simple. You can use different TextView to display hyperlinks and display the links. On clicking them you can get different selector color

Second Approach:- Use can use Spannable concept in Android to achieve this. Break the string into different part to show different hyper links. You can achieve the different color slector based upon user click. You can follow this example more from here (see try Spannable part) Change the text color of a single ClickableSpan when pressed without affecting other ClickableSpans in the same TextView

Community
  • 1
  • 1
Saurabh
  • 975
  • 2
  • 12
  • 27
  • 1st approach is not possible as the text is dynamic and I dont want to process all text for multiple textviews, for 2nd approach I'll post shortly if that works. Thanks – chin87 Apr 20 '16 at 10:59
  • Approach 2 also doesnt work, in my case autolink is used, i'll have to set spans if I want to use that solution – chin87 Apr 20 '16 at 12:25
  • Paste me what have you tried ? Let me see then what can be done for you – Saurabh Apr 20 '16 at 12:30