Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
String strings = Utils.decodeString(mChannelObj.getDescription());
SpannableStringBuilder span = new SpannableStringBuilder(strings);
Pattern webPattern = Patterns.WEB_URL;
Matcher matcher = webPattern.matcher(Utils.decodeString(mChannelObj.getDescription()));
while (matcher.find()) {
ClickableSpan clickableSpan = new ClickableSpan() {
public void onClick(@NonNull View widget) {
Logger.d(TAG, "text clicked ");
String links =;
Logger.d(TAG, "links " + links);
int startingPoint = Utils.decodeString(mChannelObj.getDescription()).indexOf(links);
int endingPoint = Utils.decodeString(mChannelObj.getDescription()).indexOf(links) + links.length();
Logger.d(TAG, startingPoint + " - " + endingPoint);
span.setSpan(clickableSpan, startingPoint, endingPoint, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
tvDescription.setText(span, TextView.BufferType.SPANNABLE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.