Suppose there is text in textView1 . It is necessary to find in it links to Internet resources and highlight them.

How to do it?

    1 answer 1

    1. Take text from textView1
    2. Parsing it according to predefined templates, can be "http: // + xxx" or "xxxx.ru", "xxx.xxx", "xxx.com"
    3. Use Spannable to highlight.

    Example

     TextView textView1 = (TextView)findViewById(R.id.text); textView1 .setText("Italic, highlighted, bold.", TextView.BufferType.SPANNABLE); Spannable span = (Spannable)textView1.getText(); span.setSpan(new BackgroundColorSpan(0xFFFFFF00), 8, 19, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); textView1 .setText(span);