Twitter 客户端中的自动链接@提及

发布于 2024-10-10 08:36:54 字数 379 浏览 12 评论 0原文

我正在构建一个基本的 Twitter 客户端应用程序。我正在尝试弄清楚如何使保存推文的 TextView 自动链接 @mentions,以便它们链接到任何人的 Twitter 页面,就像在 Twitter 网站上一样。我的猜测是,这将涉及制作一个自定义 TextView 并将其添加到已经处理网站、电子邮件、地图等自动链接的部分中。这是实现此类目标的正确方法吗?或者我应该使用库存 TextView 并通过在将推文放入视图之前解析推文来处理此问题?如果我应该采用自定义视图路线,任何人都可以为我指出正确的方向,以了解如何将此功能添加到自动链接中吗?如果我应该使用库存 TextView 并在将推文放入视图之前在 java 中处理它,我如何获得它“链接”文本我唯一的猜测是使用类似 .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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

世界等同你 2024-10-17 08:36:54

查看 Linkify 类,包括接口 Linkify.MatchFilter
Linkify.TransformFilter。您应该能够设置一个适用于 @ 链接的 MatchFilter 以及一个将它们转换为适当 URL 格式的 TransformFilter

这里有一个页面,引导您完成这些类的使用;它甚至使用 Twitter 作为使用 TransformFilter 的示例。

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.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文