Example usage for android.widget TextView getUrls

List of usage examples for android.widget TextView getUrls

Introduction

In this page you can find the example usage for android.widget TextView getUrls.

Prototype

public URLSpan[] getUrls() 

Source Link

Document

Returns the list of android.text.style.URLSpan URLSpans attached to the text (by Linkify or otherwise) if any.

Usage

From source file:com.android.mail.browse.MessageHeaderView.java

private static void stripUnderlines(TextView textView, Account account) {
    final Spannable spannable = (Spannable) textView.getText();
    final URLSpan[] urls = textView.getUrls();

    for (URLSpan span : urls) {
        final int start = spannable.getSpanStart(span);
        final int end = spannable.getSpanEnd(span);
        spannable.removeSpan(span);//  w  ww . j  a  v  a  2 s. c  o  m
        span = new EmailAddressSpan(account, span.getURL().substring(7));
        spannable.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
}

From source file:com.tct.mail.browse.MessageHeaderView.java

private void stripUnderlines(TextView textView, Account account) {
    final Spannable spannable = (Spannable) textView.getText();
    final URLSpan[] urls = textView.getUrls();

    for (URLSpan span : urls) {
        final int start = spannable.getSpanStart(span);
        final int end = spannable.getSpanEnd(span);
        spannable.removeSpan(span);/*w  w  w.j a  va2 s .  com*/
        //TS: rong-tang 2016-04-19 EMAIL BUGFIX-1951808 MOD_S
        span = new EmailAddressSpan(getContext(), account, span.getURL().substring(7), mContactInfoSource);
        ((EmailAddressSpan) span).setFragmentManager(mFragmentManager);
        //TS: rong-tang 2016-04-19 EMAIL BUGFIX-1951808 MOD_E
        spannable.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
}