Rhynoboy2009
Rhynoboy2009

Reputation: 140

How to implement hashtags in Android

How can I implement hashtags in an app in one activity? I have looked at an example of using hashtags with linkify but it uses separate activities(http://sourabhsoni.com/implementing-hashtags-in-android-application/).

Upvotes: 0

Views: 544

Answers (1)

Karakuri
Karakuri

Reputation: 38585

You can subclass ClickableSpan and define whatever special click logic should occur in onClick. You can use the same regular expression pattern used in the article and find the parts of the text that match using a Matcher object. Create a SpannableString with the existing text and add spans to it wherever the Matcher finds any matches in the text.

Upvotes: 3

Related Questions