Reputation: 140
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
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