I have a checkbox that has this text: "I agree to the terms and conditions". I need "terms and conditions" to be blue, underlined, and open a webpage when touched.
I did find the Linkify class (http://developer.android.com/reference/android/text/util/Linkify.html), but this seems to turn URLs already in text into to links.
How can I do this?
Create a hyperlink to a location on the webSelect the text or picture that you want to display as a hyperlink. Press Ctrl+K. You can also right-click the text or picture and click Link on the shortcut menu. In the Insert Hyperlink box, type or paste your link in the Address box.
Hyperlinks are clickable words or images that navigate to other web content. They can connect with almost any resource on the web. When clicked, they'll either take you to a web address immediately or, for certain types of files, give you the option to open a document with an app (like Adobe Reader to open a PDF).
Just use the string like
"I agree to the <a href="...">terms and conditions</a>"
and set movement method:
mCheckBoxTermsOfUse = (TextView) findViewById(R.id.checkBoxTermsOfUse);
mCheckBoxTermsOfUse.setMovementMethod(LinkMovementMethod.getInstance());
See api demos for details
Color the text blue and add an onClick Listener to it that launches the intent to view the URL. You can markup your text using HTML like syntax via Html.fromHtml()
. See this answer for better explanation and example.
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