本文整理匯總了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);
}
}