Indicate the hyperlink in the text of the flag?

I have a flag with the text: "I agree to the terms." I need the “conditions” to be blue, underlined and open the webpage when touched.

I found the Linkify class (http://developer.android.com/reference/android/text/util/Linkify.html), but that seems to turn the urls already in the text into links.

How can i do this?

+7
source share
2 answers

Separate the text in blue and add an onClick listener to it, which launches the intent to view the URL. You can mark up your text using HTML syntax with Html.fromHtml() . See this answer for a better explanation and example.

+3
source

Just use a string like

"I agree to the terms <a href =" ... "> </a>"

and set the move method:

 mCheckBoxTermsOfUse = (TextView) findViewById(R.id.checkBoxTermsOfUse); mCheckBoxTermsOfUse.setMovementMethod(LinkMovementMethod.getInstance()); 

See api for more details.

+15
source

All Articles