4

I'm trying to assign the below string from the strings.xml file for a TextView android:text property. I'm unable to get the link to show up as a clickable hyperlink. Any suggestions? I've tried the below techniques.

 <string name="no_device_body">click following link: <![CDATA[<a href="http://cnn.com">link1</a>]]>
 </string>

 <string name="no_device_body">click following link: http://cnn.com">
 </string>

2 Answers 2

10
<string name="no_device_body">click following link: &lt;a href="http://findmespot.com/en/index.php?cid=116">link1&lt;/a>"</string>

ref: android string.xml reading html tags problem

Sign up to request clarification or add additional context in comments.

Comments

8

What shows in the textview when you use the second string there? Just the URL but not clickable?

Do you have

android:autoLink="web"

or

android:autoLink="all"

set on your TextView in the layout xml file?

5 Comments

He is not asking how to make a link show up in a TextView but how to embed a link in a string resource.
Umm really? "I'm unable to get the link to show up as a clickable hyperlink. Any suggestions?" Seems to me like he is having trouble getting it to be clickable in a TextView. autoLink seems relavent to me, just a guess though, I've never tried URLs in the strings xml personally.
@Tim - this was what was missing.
I was able to use just the url in the resource file with the text view setting, maybe my question was a bit too vague...
@c12 what exactly worked for you? which string name format and which autolink?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.