本文整理匯總了Java中android.support.v7.view.menu.MenuBuilder.addMenuPresenter方法的典型用法代碼示例。如果您正苦於以下問題:Java MenuBuilder.addMenuPresenter方法的具體用法?Java MenuBuilder.addMenuPresenter怎麽用?Java MenuBuilder.addMenuPresenter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.view.menu.MenuBuilder
的用法示例。
在下文中一共展示了MenuBuilder.addMenuPresenter方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ensureListMenuPresenter
import android.support.v7.view.menu.MenuBuilder; //導入方法依賴的package包/類
private void ensureListMenuPresenter(Menu menu) {
if (this.mListMenuPresenter == null && (menu instanceof MenuBuilder)) {
MenuBuilder mb = (MenuBuilder) menu;
Context context = this.mDecorToolbar.getContext();
TypedValue outValue = new TypedValue();
Theme widgetTheme = context.getResources().newTheme();
widgetTheme.setTo(context.getTheme());
widgetTheme.resolveAttribute(R.attr.actionBarPopupTheme, outValue, true);
if (outValue.resourceId != 0) {
widgetTheme.applyStyle(outValue.resourceId, true);
}
widgetTheme.resolveAttribute(R.attr.panelMenuListTheme, outValue, true);
if (outValue.resourceId != 0) {
widgetTheme.applyStyle(outValue.resourceId, true);
} else {
widgetTheme.applyStyle(R.style.Theme_AppCompat_CompactMenu, true);
}
Context context2 = new ContextThemeWrapper(context, 0);
context2.getTheme().setTo(widgetTheme);
this.mListMenuPresenter = new ListMenuPresenter(context2, R.layout.abc_list_menu_item_layout);
this.mListMenuPresenter.setCallback(new PanelMenuPresenterCallback());
mb.addMenuPresenter(this.mListMenuPresenter);
}
}
示例2: initForMode
import android.support.v7.view.menu.MenuBuilder; //導入方法依賴的package包/類
public void initForMode(final ActionMode mode) {
if (this.mClose == null) {
this.mClose = LayoutInflater.from(getContext()).inflate(this.mCloseItemLayout, this, false);
addView(this.mClose);
} else if (this.mClose.getParent() == null) {
addView(this.mClose);
}
this.mClose.findViewById(R.id.action_mode_close_button).setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mode.finish();
}
});
MenuBuilder menu = (MenuBuilder) mode.getMenu();
if (this.mActionMenuPresenter != null) {
this.mActionMenuPresenter.dismissPopupMenus();
}
this.mActionMenuPresenter = new ActionMenuPresenter(getContext());
this.mActionMenuPresenter.setReserveOverflow(true);
LayoutParams layoutParams = new LayoutParams(-2, -1);
menu.addMenuPresenter(this.mActionMenuPresenter, this.mPopupContext);
this.mMenuView = (ActionMenuView) this.mActionMenuPresenter.getMenuView(this);
this.mMenuView.setBackgroundDrawable(null);
addView(this.mMenuView, layoutParams);
}
示例3: MenuPopupHelper
import android.support.v7.view.menu.MenuBuilder; //導入方法依賴的package包/類
public MenuPopupHelper(Context context, MenuBuilder menu, View anchorView,
boolean overflowOnly, int popupStyleAttr, int popupStyleRes) {
mContext = context;
mInflater = LayoutInflater.from(context);
mMenu = menu;
mAdapter = new MenuAdapter(mMenu);
mOverflowOnly = overflowOnly;
mPopupStyleAttr = popupStyleAttr;
mPopupStyleRes = popupStyleRes;
final Resources res = context.getResources();
mPopupMaxWidth = Math.max(res.getDisplayMetrics().widthPixels / 2,
res.getDimensionPixelSize(R.dimen.abc_config_prefDialogWidth));
mAnchorView = anchorView;
// Present the menu using our context, not the menu builder's context.
menu.addMenuPresenter(this, context);
}
示例4: setMenu
import android.support.v7.view.menu.MenuBuilder; //導入方法依賴的package包/類
void setMenu(MenuBuilder menu) {
if (menu != this.menu) {
if (this.menu != null) {
this.menu.removeMenuPresenter(this.listMenuPresenter);
}
this.menu = menu;
if (menu != null && this.listMenuPresenter != null) {
menu.addMenuPresenter(this.listMenuPresenter);
}
}
}
示例5: setMenu
import android.support.v7.view.menu.MenuBuilder; //導入方法依賴的package包/類
public void setMenu(MenuBuilder menu, ActionMenuPresenter outerPresenter) {
if (menu != null || this.mMenuView != null) {
ensureMenuView();
MenuBuilder oldMenu = this.mMenuView.peekMenu();
if (oldMenu != menu) {
if (oldMenu != null) {
oldMenu.removeMenuPresenter(this.mOuterActionMenuPresenter);
oldMenu.removeMenuPresenter(this.mExpandedMenuPresenter);
}
if (this.mExpandedMenuPresenter == null) {
this.mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter();
}
outerPresenter.setExpandedActionViewsExclusive(true);
if (menu != null) {
menu.addMenuPresenter(outerPresenter, this.mPopupContext);
menu.addMenuPresenter(this.mExpandedMenuPresenter, this.mPopupContext);
} else {
outerPresenter.initForMenu(this.mPopupContext, null);
this.mExpandedMenuPresenter.initForMenu(this.mPopupContext, null);
outerPresenter.updateMenuView(true);
this.mExpandedMenuPresenter.updateMenuView(true);
}
this.mMenuView.setPopupTheme(this.mPopupTheme);
this.mMenuView.setPresenter(outerPresenter);
this.mOuterActionMenuPresenter = outerPresenter;
}
}
}
示例6: ensureMenu
import android.support.v7.view.menu.MenuBuilder; //導入方法依賴的package包/類
private void ensureMenu() {
ensureMenuView();
if (this.mMenuView.peekMenu() == null) {
MenuBuilder menu = (MenuBuilder) this.mMenuView.getMenu();
if (this.mExpandedMenuPresenter == null) {
this.mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter();
}
this.mMenuView.setExpandedActionViewsExclusive(true);
menu.addMenuPresenter(this.mExpandedMenuPresenter, this.mPopupContext);
}
}