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.
This example demonstrates how do I create clickable links in a textView on android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.
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 your TextView
to make the link clickable.
There is also TextView
's android:autoLink
attribute which should also work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With