I want twitter mentions to be in redcolor and hashtags is another color,if any tweet contains any weblinks.. links should be clickable and passed through intent to another Activity(WebView
).
How can I achieve this ??
TransformFilter filter = new TransformFilter() {
public final String transformUrl(final Matcher match, String url) {
return match.group();
}
};
Pattern mentionPattern = Pattern.compile("@([A-Za-z0-9_-]+)");
String mentionScheme = "http://www.twitter.com/";
Linkify.addLinks(tvMessage, mentionPattern, mentionScheme, null, filter);
Pattern hashtagPattern = Pattern.compile("#([A-Za-z0-9_-]+)");
String hashtagScheme = "http://www.twitter.com/search/";
Linkify.addLinks(tvMessage, hashtagPattern, hashtagScheme, null, filter);
Pattern urlPattern = Patterns.WEB_URL;
Linkify.addLinks(tvMessage, urlPattern, null, null, filter);
// tvMessage.setLinkTextColor(Color.parseColor("#3467BB"));
Finally i have achieved hashtags weblinks clickable and made them very attractive by keeping different colors
using android sdk SpannableString and it's ClickableSpan .NonUnderlinedClickableSpan class