I have the following text in a string in the resources file:
<a href="mailto:mymail@mail.com"><img src="mail_big" /></a>
It shows the image fine (I implemented ImageGetter) but it is not clickable. I have tried adding the Linkify thingy but I don’t think it’s meant for this case, and so it doesn’t work. The setMovementMethod doesn’t work either.
I have tried different combinations of the above:
<a href="mailto:mymail@mail.com"><img src="mail_big" />hello</a>
Here, even the “hello” part is not clickable (neither blue nor underlined).
<a href="mailto:mymail@mail.com"><img src="mail_big" /></a>
This doesn’t even show the image.
<a href="mailto:mymail@mail.com"><img src="mail_big" /></a>
If I just write the email, without the <a> tag it works perfectly, but I would like to use the image of an envelope that the user can click on. It’s not possible to use an imagebutton because this text is in the middle of a string and so I can’t split it.
Any ideas?
Thanks!
I’ll answer my own question.
I found a solution or rather found out how to do it correctly.
All I had to do was adding the setMovementMethod call before the call to setText in the TextView and ALSO, and COMPLETELY NECESSARY, remove the attribute “android:autoLink=”all” from the layout. Apparently, parsing mails and urls in a string is mutually exclusive to interpreting the <a> link tags in a string. So one or the other but not both.
Finally my layout is just a TextView with nothing special, just width and height. The activity looks like this:
And the string is like this: