I have the following text in a string in the resources file:
<a href="mailto:
[email protected]"><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:
[email protected]"><img src="mail_big" />hello</a>
Here, even the "hello" part is not clickable (neither blue nor underlined).
<a href="mailto:
[email protected]"><img src="mail_big" /></a>
This doesn't even show the image.
<a href="mailto:
[email protected]"><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!
EDIT: I found a solution or rather found 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 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 is like this:
TextView tv = (TextView)findViewById(R.id.about_text);
tv.setMovementMethod(LinkMovementMethod.getInstance());
tv.setText(Html.fromHtml(getString(R.string.about_content), new ImageGetter(), null));
And the string is like this:
<string name="about_content"><a href="mailto:
[email protected]"><img src="mail" /></a></string>