views:

89

answers:

2

Hello...

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

+1  A: 

Take a look at that http://stackoverflow.com/questions/3026389/textview-underline-phone-number-and-hyperlink/3026883#3026883

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.

Fedor
ya this is correct to "Linkify" the WebURLs...but "Android docs" should be as a link and when user click on this link then Tager URL should be fired , same as HTML Anchor tagfor eg.<a href="target url"> Android Docs </a>
PM - Paresh Mayani
One more approach added.
Fedor
thanx for the answer.....really helpful
PM - Paresh Mayani
http://groups.google.com/group/android-developers/browse_thread/thread/c25911cc80421e9ceven this one can also be used.....@Fedor
PM - Paresh Mayani
+1  A: 

@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());
PM - Paresh Mayani