get Url SpannableString - Android android.text

Android examples for android.text:SpannableString

Description

get Url SpannableString

Demo Code

import android.content.Context;
import android.graphics.Bitmap;
import android.net.Uri;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.AbsoluteSizeSpan;
import android.text.style.BackgroundColorSpan;
import android.text.style.CharacterStyle;
import android.text.style.ForegroundColorSpan;
import android.text.style.ImageSpan;
import android.text.style.StrikethroughSpan;
import android.text.style.StyleSpan;
import android.text.style.UnderlineSpan;
import android.view.View;

public class Main{

    public static SpannableString getUrlSpan(String text, String url,
            UrlSpanOnClickListener urlSpanOnClickListener) {
        SpannableString spanString = new SpannableString(text);
        spanString.setSpan(new SimpleURLSpan(url, urlSpanOnClickListener),
                0, text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        return spanString;
    }//  www.  jav a 2  s  .  c o  m

}

Related Tutorials