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

来源:互联网 发布:微信扫码抽奖软件 编辑:程序博客网 时间:2024/05/17 17:17

完整内容,请查看: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:
另请参考:

  • ActionProvider

摘要


嵌套类

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.
创建一个新的实例。

原创粉丝点击