使用共享按钮(如 ICS 库中)而不是共享对话框 (Intent.ACTION_SEND)

发布于 2024-12-23 07:20:08 字数 536 浏览 5 评论 0原文

我正在尝试找到一种方法在我的应用程序中实现共享按钮(与标准 ICS 图库应用程序中的按钮相同,请参阅图片链接)。 http://betanews.com/2011/10/19/get-acquainted-with-the-newest-android-ice-cream-sandwich-slideshow/#11

Intent.ACTION_SEND 仅打开一个对话框选择共享选项。 Android Share Via Dialog

这工作正常,但从设计方面来看,我发现这个下拉列表选择应用程序更方便。 但我不知道该怎么做? 有人知道如何对这个按钮进行编码吗?

I am trying to find a way to impelement a share button into my app (same like the one in the standard ICS gallary app, see picture link).
http://betanews.com/2011/10/19/get-acquainted-with-the-newest-android-ice-cream-sandwich-slideshow/#11

Intent.ACTION_SEND only opens a dialoge to the select the sharing options.
Android Share Via Dialog

This works fine, but from design side, I find this drop down list to select a app much more convenient.
Yet I cant figure out how to?
Does anybody have a good Idea how this button could be coded?

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

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

发布评论

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

评论(2

女中豪杰 2024-12-30 07:20:08

这是使用 ListPopupWindow 实现的,目前仅在 Android 4.0 上可用。

That is implemented using a ListPopupWindow, which at the moment is only available on Android 4.0.

凑诗 2024-12-30 07:20:08

这是使用 SDK14+ 中提供的 ShareActionProvider 实现的。

ActionProvider 类用自定义布局替换操作项,
但它也控制所有项目的行为。当你
为操作栏中的菜单项声明一个操作提供程序,但它不是
仅控制操作栏中项目的外观
自定义布局,还处理菜单项的默认事件
当它出现在溢出菜单中时

它很容易实现,您可以按照官方文档

This is implemented using ShareActionProvider available in SDK14+.

ActionProvider class replaces an action item with a customized layout,
but it also takes control of all the item's behaviors. When you
declare an action provider for a menu item in the action bar, it not
only controls the appearance of the item in the action bar with a
custom layout, but also handles the default event for the menu item
when it appears in the overflow menu

Its quiet easy to implement, you can follow the official documentation here.

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