I have a question: How can I place a hyperlink WITHIN a text-block of normal text? I have some text and in the text I mention a URL and I want this URL to be in a different color, underlined and click-able.
I know hyperlinks in android can be placed with "Linkify".. and i have referred android docs page
Consider the same above paragraph with "android docs" i want to display in android.....
In Android, the most common way to show a text is by TextView element. The whole text in the TextView is easy to make clickable implementing the onClick attribute or by setting an onClickListener to the TextView.
@Fedor.... i have found to give links from API Demos .
this approach is finally be used for giving link in between text of paragraph.
SpannableString ss = new SpannableString("text4: Click here
to dial the phone.");
ss.setSpan(new StyleSpan(Typeface.ITALIC), 0, 6,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
ss.setSpan(new URLSpan("tel:4155551212"), 13, 17,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
TextView t4 = (TextView) findViewById(R.id.TextView01);
t4.setText(ss);
t4.setMovementMethod(LinkMovementMethod.getInstance());
Take a look at that TextView underline phone number and hyperlink
But I can see Linkify doesn't provide you the functionality you need. Not a problem, you can implement it manually. Just add ClickableSpans and handlre click. Code sample here http://www.orangeapple.org/?p=354.
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