Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Place a hyperlink in the text of a checkbox?

Tags:

android

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?

like image 539
Neil Goodman Avatar asked Apr 08 '11 18:04

Neil Goodman


People also ask

How do I embed a hyperlink in text?

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.

What is a clickable text in a hyperlink?

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).


2 Answers

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

like image 157
JustAnotherCoder Avatar answered Sep 21 '22 04:09

JustAnotherCoder


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.

like image 29
Andrew White Avatar answered Sep 20 '22 04:09

Andrew White