自动链接@mentions在Twitter客户端 [英] AutoLink @mentions in a twitter client

查看:151
本文介绍了自动链接@mentions在Twitter客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个基本的Twitter客户端应用程序。我试图找出如何让他们链接到的谁是一样的,因为它确实Twitter网站上的Twitter页面保存的鸣叫自动链接的@mentions TextView的。我的猜测是,这会涉及到制作一个自定义的TextView并将其加入到已处理的网站,电子邮件,地图和这种自动链接的部分。为实现这样的事情这个正确的方法?或者我应该使用一个TextView的股票由之前它被放入视图解析鸣叫处理这个?如果我应该去自定义视图航线任何人都可以点我如何得到这个功能添加到自动链接正确的方向?如果我应该使用TextView的股票,并在Java的处理前的鸣叫被装进认为我怎么得到它linkify我唯一的猜测是使用类似.fromHTML(文本),但我甚至不知道如果支持的标记。

I am building a basic twitter client application. I am trying to figure out how to make the TextView that holds the Tweets to autoLink the @mentions so that they link to the twitter page of whoever it is the same as it does on the twitter website. My guess is that this is going to involve making a custom TextView and adding this into the part that already handles the auto linking of websites,emails,maps and such. Is this right approach to achieving something like this? or should I be using a stock TextView and handling this by parsing the tweet before it gets put into the view? If I should be going the custom view route could anyone point me in the right direction for how to get this capability added to the autolink? And if I should be using the stock TextView and handling it in java before the tweet gets put into the view how do I get it "linkify" the text my only guess is using something like .fromHTML() but I'm not even sure if this supports the tag.

推荐答案

有一个看的 Linkify 类,包括接口 Linkify.MatchFilter
Linkify.TransformFilter 。您应该能够建立一个 MatchFilter 作品@ 链接,以及 TransformFilter 是将其转换为相应的URL格式。

Have a look at the Linkify class, including the interfaces Linkify.MatchFilter and Linkify.TransformFilter. You should be able to set up a MatchFilter that works on @ links, and a TransformFilter that translates them into the appropriate URL format.

以下是指导您完成这些类的使用量的页面;它甚至使用Twitter作为一个例子,使用 TransformFilter

Here's a page that walks you through the usage of these classes; it even uses Twitter as an example for using TransformFilter.

这篇关于自动链接@mentions在Twitter客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆