2

I have a TextView in my layout which has an attribute "clickable=true" set in XML. This is to allow it behave like a button with both text and icon. Now, I add to that TextView HTML text via call HTML.fromHtml(), and apply Linkify.addLinks after that.

The problem is: in such configuration, links are not clickable. Is there any suggestion, how to allow user click on links, other from creating custom TextView-based class?

Thanks

Anton
  • 4,395
  • 7
  • 32
  • 46
  • You want a TextView that is clickable, with links inside of it that are also clickable? That sounds like it could lead to a poor user experience, you might want to rethink your UI design. Have someone with big fingers try to hit exactly a tiny button within a small button. – Cheryl Simon Nov 23 '10 at 01:28

2 Answers2

2

try add an attribute "android:autoLink="web"" to the textview

yuchangfu
  • 36
  • 1
0

Also, I have struggled hours against the TextView before realizing that

<resources>
  <string name="mytext">Going to <a href="http://www.google.fr/">Google</a> is linkifed but NOT clickable</string>
</resources>

But this is:

<resources>
  <string name="mytext">Go to http://www.google.fr/ is linkified and clickable</string>
</resources>

In both cases, the link is recognized and styled accordingly.

rds
  • 26,253
  • 19
  • 107
  • 134
  • 1
    There is a workaround, though: http://stackoverflow.com/questions/2734270/how-do-i-make-links-in-a-textview-clickable/2746708#2746708 – rds Dec 10 '10 at 22:35