本文整理了Java中android.view.MenuItem.getSubMenu()
方法的一些代码示例,展示了MenuItem.getSubMenu()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.getSubMenu()
方法的具体详情如下:
包路径:android.view.MenuItem
类名称:MenuItem
方法名:getSubMenu
暂无
代码示例来源: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
if (item.hasSubMenu()) {
SubMenu subMenu = item.getSubMenu();
if (subMenu.hasVisibleItems()) {
if (menuType == LIST) {
代码示例来源: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
.withSelectable(false);
getItemAdapter().add(iDrawerItem);
addMenuItems(mMenuItem.getSubMenu(), true);
} else if (mMenuItem.getGroupId() != 0 || subMenu) {
iDrawerItem = new SecondaryDrawerItem()
代码示例来源:origin: Cleveroad/WaveInApp
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.main, menu);
MenuItem preset = menu.findItem(R.id.action_preset);
Menu m = preset.getSubMenu();
String[] presets = getResources().getStringArray(R.array.presets);
for (int i = 0; i < presets.length; i++) {
final int index = i + 1;
m.add(Menu.NONE, i, Menu.NONE, presets[i]).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
setPreset(index);
return true;
}
});
}
}
代码示例来源: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: zulip/zulip-android
@Override
public void onBackStackChanged() {
if (menu == null)
return;
if (narrowedList == null) {
calendar = Calendar.getInstance();
menu.findItem(R.id.filter).getSubMenu().getItem(0).setTitle(R.string.menu_today);
switchToStream();
checkForChatBoxFocusRequest();
} else if (narrowedList.filter instanceof NarrowFilterByDate) {
menu.findItem(R.id.filter).getSubMenu().getItem(0).setTitle(R.string.menu_one_day_before);
}
}
});
代码示例来源:origin: AndroidDeveloperLB/MaterialPreferenceLibrary
private static void setOnMenuItemClickListenerRecursive(Menu menu, OnMenuItemClickListener listener) {
List<Menu> menus = new ArrayList<>(1);
menus.add(menu);
while (!menus.isEmpty()) {
final Menu currentMenu = menus.remove(0);
for (int i = 0; i < currentMenu.size(); ++i) {
final MenuItem item = currentMenu.getItem(i);
item.setOnMenuItemClickListener(listener);
final SubMenu subMenu = item.getSubMenu();
if (subMenu != null)
menus.add(subMenu);
}
}
}
代码示例来源:origin: com.actionbarsherlock/actionbarsherlock
@Override
public SubMenu getSubMenu() {
if (hasSubMenu() && (mSubMenu == null)) {
mSubMenu = new SubMenuWrapper(mNativeItem.getSubMenu());
}
return mSubMenu;
}
代码示例来源:origin: com.willowtreeapps/oak-demos
@Override
public SubMenu getSubMenu() {
if (hasSubMenu() && (mSubMenu == null)) {
mSubMenu = new SubMenuWrapper(mNativeItem.getSubMenu());
}
return mSubMenu;
}
代码示例来源:origin: cemrich/zapp
public static void uncheckItems(Menu menu) {
if (menu == null) {
return;
}
for (int i = 0; i < menu.size(); i++) {
MenuItem item = menu.getItem(i);
item.setChecked(false);
uncheckItems(item.getSubMenu());
}
}
代码示例来源:origin: konradrenner/kolabnotes-android
public void overrideTags(OnDrawerSelectionChangedListener listener, Collection<Tag> tags){
final Menu overview = view.getMenu();
final SubMenu tagSubmenu = overview.findItem(R.id.navigation_tags).getSubMenu();
tagSubmenu.clear();
for(Tag tag : tags){
addTag(tagSubmenu, listener, tag);
}
}
代码示例来源:origin: konradrenner/kolabnotes-android
public MenuItem addNotebook(OnDrawerSelectionChangedListener listener, Notebook notebook){
return addNotebook(view.getContext(), view.getMenu().findItem(R.id.navigation_notebooks).getSubMenu(), listener, notebook);
}
代码示例来源:origin: konradrenner/kolabnotes-android
public void deleteNotebook(String notebookName){
final SubMenu notebookSubmenu = view.getMenu().findItem(R.id.navigation_notebooks).getSubMenu();
for(int i=0; i<notebookSubmenu.size(); i++){
final int currentId = notebookSubmenu.getItem(i).getItemId();
final String actualTitle = notebookSubmenu.getItem(i).getTitle().toString();
if(actualTitle.equals(notebookName)){
notebookSubmenu.removeItem(currentId);
}
}
}
代码示例来源: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: konradrenner/kolabnotes-android
public void overrideNotebooks(OnDrawerSelectionChangedListener listener, Collection<Notebook> notebooks){
final Menu overview = view.getMenu();
final SubMenu notebookSubmenu = overview.findItem(R.id.navigation_notebooks).getSubMenu();
notebookSubmenu.clear();
for(Notebook book : notebooks){
addNotebook(view.getContext(), notebookSubmenu, listener, book);
}
}
代码示例来源:origin: PrivacyApps/document-viewer
public static void setMenuSource(final IActionController<?> c, final Menu menu, final Object source) {
for (int i = 0, n = menu.size(); i < n; i++) {
final MenuItem item = menu.getItem(i);
final SubMenu subMenu = item.getSubMenu();
if (subMenu != null) {
setMenuSource(c, subMenu, source);
} else {
setMenuItemSource(c, item, source);
}
}
}
代码示例来源: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 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: 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;
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!