twitter linkify android all @mentions

时间:2013-02-14 10:24:09

标签: java android tweets linkify

我想在android上的mytweets应用程序中提供所有twitter @mentions的链接。如果我点击@mentions,我想打开关于@mentions的另一页。

此代码不起作用。首先,我想在推文中搜索@mentions,并给我链接@mentions,如果我在推文中点击这个@mentions,我想打开关于这个@mentions的另一页。

TextView bt = (TextView) v.findViewById(R.id.bottomtext);
Pattern atMentionPattern = Pattern.compile("@([A-Za-z0-9_]+)");
String atMentionScheme = "http://twitter.com/";

TransformFilter transformFilter = new TransformFilter() {

    public String transformUrl(final Matcher match, String url) {
        return match.group(1);
    }
};

Linkify.addLinks(bt, Linkify.ALL);
Linkify.addLinks(bt, atMentionPattern, atMentionScheme, null, transformFilter);

1 个答案:

答案 0 :(得分:0)

试试这个

 textView.setAutoLinkMask(0);    

// Recognize phone numbers and web URLs
Linkify.addLinks(text, Linkify.PHONE_NUMBERS | Linkify.WEB_URLS);

// Recognize all of the default link text patterns 
Linkify.addLinks(text, Linkify.ALL);

// Disable all default link detection
Linkify.addLinks(text, 0);

见这里是文档

http://polamreddyn.blogspot.in/2013/01/android-text-links-using-linkify.html