Android7.0中文文档(API)-- ShareActionProvider

完整内容,请查看:http://www.zhdoc.net/android/reference/android/widget/ShareActionProvider.html

ShareActionProvider

public class ShareActionProvider
extends ActionProvider

java.lang.Object
   ↳android.view.ActionProvider
    ↳android.widget.ShareActionProvider


This is a provider for a share action. It is responsible for creating views that enable data sharing and also to show a sub menu with sharing activities if the hosting item is placed on the overflow menu.
一个分享操作的provider。它负责创建支持数据分享的视图,并且如果将托管项放置在溢出菜单上,还可以显示带有分享activity的子菜单。

Here is how to use the action provider with custom backing file in a MenuItem:
下面是如何在MenuItem中使用自定义支持文件的ActionProvider:

// In Activity#onCreateOptionsMenu public boolean onCreateOptionsMenu(Menu menu) { // Get the menu item.MenuItem menuItem = menu.findItem(R.id.my_menu_item); // Get the provider and hold onto it to set/change the share intent. mShareActionProvider = (ShareActionProvider) menuItem.getActionProvider(); // Set history different from the default before getting the action // view since a call to MenuItem.getActionView()calls //onCreateActionView() which uses the backing file name.Omit this // line if using the default share history file is desired. mShareActionProvider.setShareHistoryFileName("custom_share_history.xml"); .。。} // Somewhere in the application. public void doShare(Intent shareIntent) { // When you want to share set the share intent. mShareActionProvider.setShareIntent(shareIntent); }

Note: While the sample snippet demonstrates how to use this provider in the context of a menu item, the use of the provider is not limited to menu items.
注意:尽管示例代码片段演示了如何在菜单项的上下文中使用该provider,但provider的使用并不仅限于菜单项。

See also:
另请参考:

摘要


嵌套类

interfaceShareActionProvider.OnShareTargetSelectedListener

Listener for the event of selecting a share target. 
监听器,其监听选择一个共享目标的事件。 

常量

StringDEFAULT_SHARE_HISTORY_FILE_NAME

The default name for storing share history.
存储分享历史的默认文件名称。

Public构造方法

ShareActionProvider(Context context)

Creates a new instance.
创建一个新的实例。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值