【问题标题】:twitter linkify android all @mentionstwitter链接android所有@mentions
【发布时间】:2013-02-14 10:24:08
【问题描述】:

我想在 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);

【问题讨论】:

    标签: java android tweets linkify


    【解决方案1】:

    这样试试

     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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-20
      • 2018-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-18
      • 1970-01-01
      • 2011-06-25
      相关资源
      最近更新 更多