remove Underlines string from Spannable - Android android.text

Android examples for android.text:SpannableString

Description

remove Underlines string from Spannable

Demo Code

import android.text.Spannable;
import android.text.style.URLSpan;

public class Main{

    public static void removeUnderlines(Spannable p_Text) {
        URLSpan[] spans = p_Text/*from w  ww  . ja v  a2 s  .  c o  m*/
                .getSpans(0, p_Text.length(), URLSpan.class);

        for (URLSpan span : spans) {
            int start = p_Text.getSpanStart(span);
            int end = p_Text.getSpanEnd(span);
            p_Text.removeSpan(span);
            span = new URLSpanNoUnderline(span.getURL());
            p_Text.setSpan(span, start, end, 0);
        }

    }

}

Related Tutorials