I usually set up some kind of AlertDialog
to fire off when a user first uses one of my apps and I explain how to use the app and give an overall introduction to what they just downloaded. I also usually load my strings from a strings.xml
file.
What I want to do is make one of the words in my string resource clickable like a hyperlink on a web page. Basically you'd have an AlertDialog
and within the string resource there would be a highlighted word or possibly just a web address that they could press. I suppose I could just add a button that would take them to the site but I just wanted to know if making a word in your string resource a clickable hyperlink was possible.
Just use an HTML format link in your resource:
<string name="my_link"><a href="http://somesite.com/">Click me!</a></string>
You can then use
setMovementMethod(LinkMovementMethod.getInstance())
on yourTextView
to make the link clickable.There is also
TextView
'sandroid:autoLink
attribute which should also work.Android doesn't make strings that contain valid link clickable automatically. What you can do, is add custom view to your dialog and use WebView to show the alert message. In that case, you can store html in your resources and they will be clickable.
alert_dialog_layout.xml
I found something interesting. Let me know if any of you observed this.
Below hyperlink is not working if you use
but works with
but if you use the following link it works with both