I am trying to recognise hashtags in my TextView and make them clickable such that I can take the user to another View when they click on the Hashtag.
I managed to i
Yes you can do it, you need to use ClickableSpan with SpannableString
paste this code inside your while loop
final String tag = matcher.group(0);
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(View textView) {
Log.e("click","click " + tag);
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
}
};
hashText.setSpan(clickableSpan, matcher.start(), matcher.end(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
Dont forget to set setMovementMethod() on your TextView
holder.caption.setMovementMethod(LinkMovementMethod.getInstance());