A smart TextView for android that detects #hashtags, @mentions, URLs, emails, phone numbers and more.
- Detect emails, mobile numbers, URLs
- Detect #hash_tags and @mentions
- Use default intents or set custom callbacks.
- Set different colors for each pattern.
compile 'com.priyankvex:smarttextview:1.0.1'
In layout xml file
<com.wordpress.priyankvex.smarttextview.SmartTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="9pt"
android:id="@+id/textView"
/>
In java Activity or Fragment
mSmartTextView = (SmartTextView) findViewById(R.id.textView);
mSmartTextView.setEmailColorCode("#3cb371");
mSmartTextView.setPhoneNumberColorCode("#ff33aa");
mSmartTextView.setHashTagColorCode("#f37735");
mSmartTextView.setUrlColorCode("#ffc425");
mSmartTextView.setMentionColorCode("#57b884");
mSmartTextView.setDetectMentions(true);
mSmartTextView.setDetectHashTags(true);
mSmartTextView.setText(sampleText);
mSmartTextView.setSmartTextCallback(this);
To use custom callbacks
implements SmartTextCallback