本文整理汇总了Java中android.support.v4.view.MenuItemCompat.setActionProvider方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItemCompat.setActionProvider方法的具体用法?Java MenuItemCompat.setActionProvider怎么用?Java MenuItemCompat.setActionProvider使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.MenuItemCompat
的用法示例。
在下文中一共展示了MenuItemCompat.setActionProvider方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateActionMode
import android.support.v4.view.MenuItemCompat; //导入方法依赖的package包/类
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
menu.add(0, R.id.select_all, 0, R.string.select_all).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
menu.add(0, R.id.cut, 0, R.string.cut).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
menu.add(0, R.id.copy, 0, R.string.copy).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
MenuItem pasteMenu = menu.add(0, R.id.paste, 0, R.string.paste);
pasteMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
pasteMenu.setEnabled(fileClipboard.canPaste());
renameMenu = menu.add(0, R.id.rename, 0, R.string.rename);
renameMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
shareMenu = menu.add(0, R.id.share, 0, R.string.share);
shareMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
shareActionProvider = new ShareActionProvider(context);
shareActionProvider.setOnShareTargetSelectedListener(this);
MenuItemCompat.setActionProvider(shareMenu, shareActionProvider);
menu.add(0, R.id.delete, 0, R.string.delete).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
return true;
}
示例2: onCreateOptionsMenu
import android.support.v4.view.MenuItemCompat; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
boolean ret = super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.cast_menu, menu);
if(ArchosVideoCastManager.isCastAvailable()) {
mMediaRouteMenuItem = VideoCastManager.getInstance().addMediaRouterButton(menu, R.id.media_route_menu_item);
showOverlay();
VideoCastManager.getInstance().addVideoCastConsumer(new VideoCastConsumerImpl() {
@Override
public void onCastAvailabilityChanged(boolean castPresent) {
if (castPresent) {
showOverlay();
}
}
});
}
/// /setHomeButtonsetHomeButton();
MenuItem item = menu.add(MENU_SEARCH_GROUP, MENU_SEARCH_ITEM, Menu.NONE, R.string.search_title);
item.setIcon(android.R.drawable.ic_menu_search);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
mSearchView = new SearchView(this);
mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
item.setActionView(mSearchView);
mSearchItem = item;
MenuItem menuItem = menu.add(MENU_SCRAPER_GROUP, MENU_START_AUTO_SCRAPER_ACTIVITY, Menu.NONE,
R.string.start_auto_scraper_activity);
menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
MenuItemCompat.setActionProvider(menuItem, mNewVideosActionProvider);
mNewVideosActionProvider.manageVisibility(menuItem);
menuItem = menu.add(MENU_PRIVATE_MODE_GROUP, MENU_PRIVATE_MODE_ITEM, Menu.CATEGORY_SECONDARY, R.string.activate_private_mode);
menuItem.setIcon(R.drawable.ic_menu_private_mode);
menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
return ret;
}
示例3: setItem
import android.support.v4.view.MenuItemCompat; //导入方法依赖的package包/类
private void setItem(MenuItem item) {
item.setChecked(this.itemChecked).setVisible(this.itemVisible).setEnabled(this.itemEnabled).setCheckable(this.itemCheckable >= 1).setTitleCondensed(this.itemTitleCondensed).setIcon(this.itemIconResId).setAlphabeticShortcut(this.itemAlphabeticShortcut).setNumericShortcut(this.itemNumericShortcut);
if (this.itemShowAsAction >= 0) {
MenuItemCompat.setShowAsAction(item, this.itemShowAsAction);
}
if (this.itemListenerMethodName != null) {
if (SupportMenuInflater.this.mContext.isRestricted()) {
throw new IllegalStateException("The android:onClick attribute cannot be used within a restricted context");
}
item.setOnMenuItemClickListener(new InflatedOnMenuItemClickListener(SupportMenuInflater.this.getRealOwner(), this.itemListenerMethodName));
}
if (item instanceof MenuItemImpl) {
MenuItemImpl impl = (MenuItemImpl) item;
}
if (this.itemCheckable >= 2) {
if (item instanceof MenuItemImpl) {
((MenuItemImpl) item).setExclusiveCheckable(true);
} else if (item instanceof MenuItemWrapperICS) {
((MenuItemWrapperICS) item).setExclusiveCheckable(true);
}
}
boolean actionViewSpecified = false;
if (this.itemActionViewClassName != null) {
MenuItemCompat.setActionView(item, (View) newInstance(this.itemActionViewClassName, SupportMenuInflater.ACTION_VIEW_CONSTRUCTOR_SIGNATURE, SupportMenuInflater.this.mActionViewConstructorArguments));
actionViewSpecified = true;
}
if (this.itemActionViewLayout > 0) {
if (actionViewSpecified) {
Log.w(SupportMenuInflater.LOG_TAG, "Ignoring attribute 'itemActionViewLayout'. Action view already specified.");
} else {
MenuItemCompat.setActionView(item, this.itemActionViewLayout);
}
}
if (this.itemActionProvider != null) {
MenuItemCompat.setActionProvider(item, this.itemActionProvider);
}
}