当前位置: 首页>>代码示例>>Java>>正文


Java MenuItemImpl类代码示例

本文整理汇总了Java中android.support.v7.view.menu.MenuItemImpl的典型用法代码示例。如果您正苦于以下问题:Java MenuItemImpl类的具体用法?Java MenuItemImpl怎么用?Java MenuItemImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MenuItemImpl类属于android.support.v7.view.menu包,在下文中一共展示了MenuItemImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildMenuView

import android.support.v7.view.menu.MenuItemImpl; //导入依赖的package包/类
public void buildMenuView() {
    if (mButtons != null) {
        for (BottomNavigationItemView item : mButtons) {
            sItemPool.release(item);
        }
    }
    removeAllViews();
    mButtons = new BottomNavigationItemView[mMenu.size()];
    mShiftingMode = mMenu.size() > 3;
    for (int i = 0; i < mMenu.size(); i++) {
        mPresenter.setUpdateSuspended(true);
        mMenu.getItem(i).setCheckable(true);
        mPresenter.setUpdateSuspended(false);
        BottomNavigationItemView child = getNewItem();
        mButtons[i] = child;
        child.setIconTintList(mItemIconTint);
        child.setTextColor(mItemTextColor);
        child.setItemBackground(mItemBackgroundRes);
        child.setShiftingMode(mShiftingMode);
        child.initialize((MenuItemImpl) mMenu.getItem(i), 0);
        child.setItemPosition(i);
        child.setOnClickListener(mOnClickListener);
        addView(child);
    }
}
 
开发者ID:Trumeet,项目名称:MiPushFramework,代码行数:26,代码来源:BottomNavigationMenuView.java

示例2: expandItemActionView

import android.support.v7.view.menu.MenuItemImpl; //导入依赖的package包/类
public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item) {
    Toolbar.this.ensureCollapseButtonView();
    if (Toolbar.this.mCollapseButtonView.getParent() != Toolbar.this) {
        Toolbar.this.addView(Toolbar.this.mCollapseButtonView);
    }
    Toolbar.this.mExpandedActionView = item.getActionView();
    this.mCurrentExpandedItem = item;
    if (Toolbar.this.mExpandedActionView.getParent() != Toolbar.this) {
        LayoutParams lp = Toolbar.this.generateDefaultLayoutParams();
        lp.gravity = GravityCompat.START | (Toolbar.this.mButtonGravity & 112);
        lp.mViewType = 2;
        Toolbar.this.mExpandedActionView.setLayoutParams(lp);
        Toolbar.this.addView(Toolbar.this.mExpandedActionView);
    }
    Toolbar.this.removeChildrenForExpandedActionView();
    Toolbar.this.requestLayout();
    item.setActionViewExpanded(true);
    if (Toolbar.this.mExpandedActionView instanceof CollapsibleActionView) {
        ((CollapsibleActionView) Toolbar.this.mExpandedActionView).onActionViewExpanded();
    }
    return true;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:23,代码来源:Toolbar.java

示例3: ActionButtonSubmenu

import android.support.v7.view.menu.MenuItemImpl; //导入依赖的package包/类
public ActionButtonSubmenu(Context context, SubMenuBuilder subMenu) {
    super(context, subMenu, null, false, R.attr.actionOverflowMenuStyle);
    this.mSubMenu = subMenu;
    if (!((MenuItemImpl) subMenu.getItem()).isActionButton()) {
        setAnchorView(ActionMenuPresenter.this.mOverflowButton == null ? (View) ActionMenuPresenter.this.mMenuView : ActionMenuPresenter.this.mOverflowButton);
    }
    setCallback(ActionMenuPresenter.this.mPopupPresenterCallback);
    boolean preserveIconSpacing = false;
    int count = subMenu.size();
    for (int i = 0; i < count; i++) {
        MenuItem childItem = subMenu.getItem(i);
        if (childItem.isVisible() && childItem.getIcon() != null) {
            preserveIconSpacing = true;
            break;
        }
    }
    setForceShowIcon(preserveIconSpacing);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:ActionMenuPresenter.java

示例4: createInstanceState

import android.support.v7.view.menu.MenuItemImpl; //导入依赖的package包/类
public Bundle createInstanceState() {
    Bundle state = new Bundle();
    if (this.mCheckedItem != null) {
        state.putInt(STATE_CHECKED_ITEM, this.mCheckedItem.getItemId());
    }
    SparseArray<ParcelableSparseArray> actionViewStates = new SparseArray();
    Iterator i$ = this.mItems.iterator();
    while (i$.hasNext()) {
        NavigationMenuItem navigationMenuItem = (NavigationMenuItem) i$.next();
        if (navigationMenuItem instanceof NavigationMenuTextItem) {
            MenuItemImpl item = ((NavigationMenuTextItem) navigationMenuItem).getMenuItem();
            View actionView = item != null ? item.getActionView() : null;
            if (actionView != null) {
                ParcelableSparseArray container = new ParcelableSparseArray();
                actionView.saveHierarchyState(container);
                actionViewStates.put(item.getItemId(), container);
            }
        }
    }
    state.putSparseParcelableArray(STATE_ACTION_VIEWS, actionViewStates);
    return state;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:23,代码来源:NavigationMenuPresenter.java

示例5: restoreInstanceState

import android.support.v7.view.menu.MenuItemImpl; //导入依赖的package包/类
public void restoreInstanceState(Bundle state) {
    Iterator i$;
    int checkedItem = state.getInt(STATE_CHECKED_ITEM, 0);
    if (checkedItem != 0) {
        this.mUpdateSuspended = true;
        i$ = this.mItems.iterator();
        while (i$.hasNext()) {
            NavigationMenuItem item = (NavigationMenuItem) i$.next();
            if (item instanceof NavigationMenuTextItem) {
                MenuItemImpl menuItem = ((NavigationMenuTextItem) item).getMenuItem();
                if (menuItem != null && menuItem.getItemId() == checkedItem) {
                    setCheckedItem(menuItem);
                    break;
                }
            }
        }
        this.mUpdateSuspended = false;
        prepareMenuItems();
    }
    SparseArray<ParcelableSparseArray> actionViewStates = state.getSparseParcelableArray(STATE_ACTION_VIEWS);
    i$ = this.mItems.iterator();
    while (i$.hasNext()) {
        NavigationMenuItem navigationMenuItem = (NavigationMenuItem) i$.next();
        if (navigationMenuItem instanceof NavigationMenuTextItem) {
            MenuItemImpl item2 = ((NavigationMenuTextItem) navigationMenuItem).getMenuItem();
            View actionView = item2 != null ? item2.getActionView() : null;
            if (actionView != null) {
                actionView.restoreHierarchyState((SparseArray) actionViewStates.get(item2.getItemId()));
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:33,代码来源:NavigationMenuPresenter.java

示例6: initialize

import android.support.v7.view.menu.MenuItemImpl; //导入依赖的package包/类
@Override
public void initialize(MenuItemImpl itemData, int menuType) {
    mItemData = itemData;

    setVisibility(itemData.isVisible() ? VISIBLE : GONE);

    if (getBackground() == null) {
        ViewCompat.setBackground(this, createDefaultBackground());
    }

    setCheckable(itemData.isCheckable());
    setChecked(itemData.isChecked());
    setEnabled(itemData.isEnabled());
    setTitle(itemData.getTitle());
    setIcon(itemData.getIcon());
    setActionView(itemData.getActionView());
    adjustAppearance();
}
 
开发者ID:jruesga,项目名称:rview,代码行数:19,代码来源:DrawerNavigationMenuItemView.java

示例7: createInstanceState

import android.support.v7.view.menu.MenuItemImpl; //导入依赖的package包/类
public Bundle createInstanceState() {
    Bundle state = new Bundle();
    if (mCheckedItem != null) {
        state.putInt(STATE_CHECKED_ITEM, mCheckedItem.getItemId());
    }
    // Store the states of the action views.
    SparseArray<ParcelableSparseArray> actionViewStates = new SparseArray<>();
    for (NavigationMenuItem navigationMenuItem : mItems) {
        if (navigationMenuItem instanceof NavigationMenuTextItem) {
            MenuItemImpl item = ((NavigationMenuTextItem) navigationMenuItem).getMenuItem();
            View actionView = item != null ? item.getActionView() : null;
            if (actionView != null) {
                ParcelableSparseArray container = new ParcelableSparseArray();
                actionView.saveHierarchyState(container);
                actionViewStates.put(item.getItemId(), container);
            }
        }
    }
    state.putSparseParcelableArray(STATE_ACTION_VIEWS, actionViewStates);
    return state;
}
 
开发者ID:jruesga,项目名称:rview,代码行数:22,代码来源:DrawerNavigationMenuPresenter.java

示例8: prepareMenu

import android.support.v7.view.menu.MenuItemImpl; //导入依赖的package包/类
private void prepareMenu(Menu m) {
    if(m != null) {
        SwitchCompat switchh = (SwitchCompat) ((MenuItemImpl) m.findItem(R.id.menu_item_switch)).getActionView().findViewById(R.id.pluginEnabledSwitch);
        if(isKeepassInstalled()) {
            switchh.setEnabled(true);
            switchh.setChecked(isEnabled());
            switchh.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                    enableDisablePlugin();
                }
            });
        } else
            switchh.setChecked(false);

        try {
            PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
            String version = pInfo.versionName;
            m.findItem(R.id.menuVersion).setTitle("v:" + version);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:andreacioni,项目名称:KeeLink,代码行数:25,代码来源:MainActivity.java

示例9: isActionViewOf

import android.support.v7.view.menu.MenuItemImpl; //导入依赖的package包/类
/**
 * Returns a matcher that matches the action view of the specified menu item.
 *
 * @param menu The menu
 * @param id The ID of the menu item
 */
public static Matcher<View> isActionViewOf(@NonNull final Menu menu, @IdRes final int id) {
  return new TypeSafeMatcher<View>() {

    private Resources resources;

    @Override
    protected boolean matchesSafely(View view) {
      resources = view.getResources();
      MenuItemImpl item = (MenuItemImpl) menu.findItem(id);
      return item != null && item.getActionView() == view;
    }

    @Override
    public void describeTo(Description description) {
      String name;
      if (resources != null) {
        name = resources.getResourceName(id);
      } else {
        name = Integer.toString(id);
      }
      description.appendText("is action view of menu item " + name);
    }
  };
}
 
开发者ID:material-components,项目名称:material-components-android,代码行数:31,代码来源:TestUtilsMatchers.java

示例10: addInternal

import android.support.v7.view.menu.MenuItemImpl; //导入依赖的package包/类
@Override
protected MenuItem addInternal(int group, int id, int categoryOrder, CharSequence title) {
  if (size() + 1 > MAX_ITEM_COUNT) {
    throw new IllegalArgumentException(
        "Maximum number of items supported by BottomNavigationView is "
            + MAX_ITEM_COUNT
            + ". Limit can be checked with BottomNavigationView#getMaxItemCount()");
  }
  stopDispatchingItemsChanged();
  final MenuItem item = super.addInternal(group, id, categoryOrder, title);
  if (item instanceof MenuItemImpl) {
    ((MenuItemImpl) item).setExclusiveCheckable(true);
  }
  startDispatchingItemsChanged();
  return item;
}
 
开发者ID:material-components,项目名称:material-components-android,代码行数:17,代码来源:BottomNavigationMenu.java

示例11: createInstanceState

import android.support.v7.view.menu.MenuItemImpl; //导入依赖的package包/类
public Bundle createInstanceState() {
  Bundle state = new Bundle();
  if (checkedItem != null) {
    state.putInt(STATE_CHECKED_ITEM, checkedItem.getItemId());
  }
  // Store the states of the action views.
  SparseArray<ParcelableSparseArray> actionViewStates = new SparseArray<>();
  for (int i = 0, size = items.size(); i < size; i++) {
    NavigationMenuItem navigationMenuItem = items.get(i);
    if (navigationMenuItem instanceof NavigationMenuTextItem) {
      MenuItemImpl item = ((NavigationMenuTextItem) navigationMenuItem).getMenuItem();
      View actionView = item != null ? item.getActionView() : null;
      if (actionView != null) {
        ParcelableSparseArray container = new ParcelableSparseArray();
        actionView.saveHierarchyState(container);
        actionViewStates.put(item.getItemId(), container);
      }
    }
  }
  state.putSparseParcelableArray(STATE_ACTION_VIEWS, actionViewStates);
  return state;
}
 
开发者ID:material-components,项目名称:material-components-android,代码行数:23,代码来源:NavigationMenuPresenter.java

示例12: initialize

import android.support.v7.view.menu.MenuItemImpl; //导入依赖的package包/类
@Override
public void initialize(MenuItemImpl itemData, int menuType) {
  this.itemData = itemData;

  setVisibility(itemData.isVisible() ? VISIBLE : GONE);

  if (getBackground() == null) {
    ViewCompat.setBackground(this, createDefaultBackground());
  }

  setCheckable(itemData.isCheckable());
  setChecked(itemData.isChecked());
  setEnabled(itemData.isEnabled());
  setTitle(itemData.getTitle());
  setIcon(itemData.getIcon());
  setActionView(itemData.getActionView());
  setContentDescription(itemData.getContentDescription());
  TooltipCompat.setTooltipText(this, itemData.getTooltipText());
  adjustAppearance();
}
 
开发者ID:material-components,项目名称:material-components-android,代码行数:21,代码来源:NavigationMenuItemView.java

示例13: createInstanceState

import android.support.v7.view.menu.MenuItemImpl; //导入依赖的package包/类
public Bundle createInstanceState() {
  Bundle state = new Bundle();
  if (mCheckedItem != null) {
    state.putInt(STATE_CHECKED_ITEM, mCheckedItem.getItemId());
  }
  // Store the states of the action views.
  SparseArray<ParcelableSparseArray> actionViewStates = new SparseArray<>();
  for (int i = 0, size = mItems.size(); i < size; i++) {
    NavigationMenuItem navigationMenuItem = mItems.get(i);
    if (navigationMenuItem instanceof NavigationMenuTextItem) {
      MenuItemImpl item = ((NavigationMenuTextItem) navigationMenuItem).getMenuItem();
      View actionView = item != null ? item.getActionView() : null;
      if (actionView != null) {
        ParcelableSparseArray container = new ParcelableSparseArray();
        actionView.saveHierarchyState(container);
        actionViewStates.put(item.getItemId(), container);
      }
    }
  }
  state.putSparseParcelableArray(STATE_ACTION_VIEWS, actionViewStates);
  return state;
}
 
开发者ID:google,项目名称:iosched,代码行数:23,代码来源:NavigationMenuPresenter.java

示例14: initialize

import android.support.v7.view.menu.MenuItemImpl; //导入依赖的package包/类
@Override
public void initialize(MenuItemImpl itemData, int menuType) {
  mItemData = itemData;

  setVisibility(itemData.isVisible() ? VISIBLE : GONE);

  if (getBackground() == null) {
    ViewCompat.setBackground(this, createDefaultBackground());
  }

  setCheckable(itemData.isCheckable());
  setChecked(itemData.isChecked());
  setEnabled(itemData.isEnabled());
  setTitle(itemData.getTitle());
  setIcon(itemData.getIcon());
  setActionView(itemData.getActionView());
  adjustAppearance();
}
 
开发者ID:google,项目名称:iosched,代码行数:19,代码来源:NavigationMenuItemView.java

示例15: filter

import android.support.v7.view.menu.MenuItemImpl; //导入依赖的package包/类
private List<MenuItemImpl> filter(List<MenuItemImpl> target, MenuItemImplPredicate predicate) {
    List<MenuItemImpl> result = new ArrayList<>();
    for (MenuItemImpl element : target) {
        if (predicate.apply(element)) {
            result.add(element);
        }
    }
    return result;
}
 
开发者ID:lurbas,项目名称:ListItemView,代码行数:10,代码来源:MenuView.java


注:本文中的android.support.v7.view.menu.MenuItemImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。