本文整理了Java中android.view.MenuItem.hasSubMenu()
方法的一些代码示例,展示了MenuItem.hasSubMenu()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.hasSubMenu()
方法的具体详情如下:
包路径:android.view.MenuItem
类名称:MenuItem
方法名:hasSubMenu
暂无
代码示例来源:origin: Flipboard/bottomsheet
public boolean isEnabled() {
// Separators and subheaders never respond to click
return menuItem != null && !menuItem.hasSubMenu() && menuItem.isEnabled();
}
代码示例来源:origin: square/assertj-android
public MenuItemAssert hasSubMenu() {
isNotNull();
assertThat(actual.hasSubMenu()) //
.overridingErrorMessage("Expected to have sub-menu but sub-menu was not present.") //
.isTrue();
return this;
}
代码示例来源:origin: square/assertj-android
public MenuItemAssert hasNoSubMenu() {
isNotNull();
assertThat(actual.hasSubMenu()) //
.overridingErrorMessage("Expected to not have a sub-menu but sub-menu was present.") //
.isFalse();
return this;
}
代码示例来源:origin: pockethub/PocketHub
private void setUpNavigationMenu() {
MenuItem organizationContainer = navigationView.getMenu().findItem(R.id.navigation_organizations);
if (organizationContainer.hasSubMenu()) {
SubMenu organizationsMenu = organizationContainer.getSubMenu();
for (int i = 1; i < orgs.size(); i++) {
User organization = orgs.get(i);
if (organizationsMenu.findItem(organization.id().intValue()) == null) {
MenuItem organizationMenuItem = organizationsMenu.add(Menu.NONE, organization.id().intValue(), Menu.NONE, organization.name() != null ? organization.name() : organization.login());
organizationMenuItem.setIcon(R.drawable.ic_github_organization_black_24dp);
//Because of tinting the real image would became a grey block
//avatars.bind(organizationMenuItem, organization);
menuItemOrganizationMap.put(organizationMenuItem, organization);
}
}
} else {
throw new IllegalStateException("Menu item " + organizationContainer + " should have a submenu");
}
}
代码示例来源:origin: Flipboard/bottomsheet
@Override
public int getItemViewType(int position) {
SheetMenuItem item = getItem(position);
if (item.isSeparator()) {
return VIEW_TYPE_SEPARATOR;
} else if (item.getMenuItem().hasSubMenu()) {
return VIEW_TYPE_SUBHEADER;
} else {
return VIEW_TYPE_NORMAL;
}
}
代码示例来源:origin: Flipboard/bottomsheet
MenuItem item = menu.getItem(i);
if (item.isVisible()) {
if (item.hasSubMenu()) {
代码示例来源:origin: code-mc/material-icon-lib
private void populateIcons(Menu menu, IconData root, int defaultIconColor) {
for(int i = 0; i < menu.size(); i++){
MenuItem m = menu.getItem(i);
IconData d = root.children.get(i);
if(m.hasSubMenu()){
populateIcons(m.getSubMenu(), d, defaultIconColor);
}
if(d.itemIconResId >= 0)
m.setIcon(
MaterialDrawableBuilder.with(mContext)
.setIcon(MaterialDrawableBuilder.IconValue.values()[d.itemIconResId])
.setColor(d.itemColor != -1 ? d.itemColor : defaultIconColor)
.setToActionbarSize()
.build()
);
}
}
代码示例来源:origin: mikepenz/MaterialDrawer
getItemAdapter().add(iDrawerItem);
if (mMenuItem.hasSubMenu()) {
iDrawerItem = new PrimaryDrawerItem()
.withName(mMenuItem.getTitle().toString())
代码示例来源:origin: fossasia/pslab-android
private void selectNavMenu() {
int size_menu = navigationView.getMenu().size();
for (int i = 0; i < size_menu; i++) {
final MenuItem item = navigationView.getMenu().getItem(i);
if (item.hasSubMenu()) {
unCheckAllMenuItems(item.getSubMenu());
} else {
item.setChecked(false);
}
}
switch (navItemIndex) {
case 0:
case 1:
case 2:
navigationView.getMenu().getItem(navItemIndex).setChecked(true);
break;
case 3:
navigationView.getMenu().getItem(4).getSubMenu().getItem(1).setChecked(true);
break;
case 4:
navigationView.getMenu().getItem(4).getSubMenu().getItem(0).setChecked(true);
break;
default:
navigationView.getMenu().getItem(0).setChecked(true);
break;
}
}
代码示例来源:origin: com.actionbarsherlock/actionbarsherlock
@Override
public boolean hasSubMenu() {
return mNativeItem.hasSubMenu();
}
代码示例来源:origin: com.willowtreeapps/oak-demos
@Override
public boolean hasSubMenu() {
return mNativeItem.hasSubMenu();
}
代码示例来源:origin: kingargyle/adt-leanback-support
boolean shouldAddChooserIntent(MenuItem item) {
return !item.hasSubMenu();
}
}
代码示例来源:origin: com.squareup.assertj/assertj-android
public MenuItemAssert hasSubMenu() {
isNotNull();
assertThat(actual.hasSubMenu()) //
.overridingErrorMessage("Expected to have sub-menu but sub-menu was not present.") //
.isTrue();
return this;
}
代码示例来源:origin: com.squareup.assertj/assertj-android
public MenuItemAssert hasNoSubMenu() {
isNotNull();
assertThat(actual.hasSubMenu()) //
.overridingErrorMessage("Expected to not have a sub-menu but sub-menu was present.") //
.isFalse();
return this;
}
代码示例来源:origin: derry/delion
@Override
public int getItemViewType(int position) {
MenuItem item = getItem(position);
int viewCount = item.hasSubMenu() ? item.getSubMenu().size() : 1;
if (item.getItemId() == R.id.update_menu_id) {
return UPDATE_MENU_ITEM;
} else if (viewCount == 4) {
return FOUR_BUTTON_MENU_ITEM;
} else if (viewCount == 3) {
return THREE_BUTTON_MENU_ITEM;
} else if (viewCount == 2) {
return TITLE_BUTTON_MENU_ITEM;
}
return STANDARD_MENU_ITEM;
}
代码示例来源:origin: KDE/kdeconnect-android
private static void uncheckAllMenuItems(Menu menu) {
int size = menu.size();
for (int i = 0; i < size; i++) {
MenuItem item = menu.getItem(i);
if(item.hasSubMenu()) {
uncheckAllMenuItems(item.getSubMenu());
} else {
item.setChecked(false);
}
}
}
代码示例来源:origin: marzika/Snapprefs
private void selectNavItemFromSub(String entryName, SubMenu subMenu) {
for(int i = 0; i < subMenu.size(); i++) {
MenuItem item = subMenu.getItem(i);
if( item.hasSubMenu() )
selectNavItemFromSub(entryName, item.getSubMenu());
else {
if (item.getTitle().equals(entryName)) {
selectNavItem(item);
return;
}
}
}
}
代码示例来源:origin: LonamiWebs/Stringlate
/**
* Try to tint all {@link Menu}s {@link MenuItem}s with given color
*/
@SuppressWarnings("ConstantConditions")
public void tintMenuItems(Menu menu, boolean recurse, @ColorInt int iconColor) {
for (int i = 0; i < menu.size(); i++) {
MenuItem item = menu.getItem(i);
tintDrawable(item.getIcon(), iconColor);
if (item.hasSubMenu() && recurse) {
tintMenuItems(item.getSubMenu(), recurse, iconColor);
}
}
}
代码示例来源:origin: marzika/Snapprefs
private void selectNavItem(String entryName) {
for(int i = 0; i < mNavigationView.getMenu().size(); i++) {
MenuItem item = mNavigationView.getMenu().getItem(i);
if( item.hasSubMenu() ) {
selectNavItemFromSub(entryName, item.getSubMenu());
} else {
if (item.getTitle().equals(entryName)) {
selectNavItem(item);
return;
}
}
}
}
代码示例来源:origin: jahirfiquitiva/IconShowcase
public static void tintMenu(final Menu menu, @ColorInt final int iconsColor) {
if (menu != null) {
for (int i = 0, size = menu.size(); i < size; i++) {
MenuItem menuItem = menu.getItem(i);
if (isInOverflow(menuItem)) {
colorMenuItem(menuItem, iconsColor);
}
if (menuItem.hasSubMenu()) {
SubMenu subMenu = menuItem.getSubMenu();
for (int j = 0; j < subMenu.size(); j++) {
colorMenuItem(subMenu.getItem(j), iconsColor);
}
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!