tags:

views:

27

answers:

0

I'd like to define a TextView in XML which contains text which is a link to a URL. Essentially the semantics of the anchor HTML tag. <a>

I have been able to do most of what I want with, the android:autoLink="web" attribute to TextView. However, the text has to contain the URL and it is displayed to the user. I'd like to display different text which links to the URL.

Example: I can say,

<TextView android:text="http://foo.com" android:autoLink="web">

But then the users sees, "http://foo.com". I'd rather say something else, like "bar".

I tried defining the string in a string resource and using a link, such as

<string name="test"><a href="foo.com">bar</a>

The string shows up properly formatted, but you cannot click on it.