Java Code Examples for android.view.Menu#addSubMenu()

The following examples show how to use android.view.Menu#addSubMenu() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From rcloneExplorer with MIT License 6 votes vote down vote up
private void pinRemotesToDrawer() {
    Menu menu = navigationView.getMenu();
    MenuItem existingMenu = menu.findItem(1);
    if (existingMenu != null) {
        return;
    }

    SubMenu subMenu = menu.addSubMenu(R.id.drawer_pinned_header, 1, Menu.NONE, R.string.nav_drawer_pinned_header);

    List<RemoteItem> remoteItems = rclone.getRemotes();
    Collections.sort(remoteItems);
    for (RemoteItem remoteItem : remoteItems) {
        if (remoteItem.isDrawerPinned()) {
            MenuItem menuItem = subMenu.add(R.id.nav_pinned, availableDrawerPinnedRemoteId, Menu.NONE, remoteItem.getName());
            drawerPinnedRemoteIds.put(availableDrawerPinnedRemoteId, remoteItem);
            availableDrawerPinnedRemoteId++;
            menuItem.setIcon(remoteItem.getRemoteIcon());
        }
    }
}
 
Example 2
Source File: ThreadsPage.java    From Dashchan with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu) {
	menu.add(0, OPTIONS_MENU_REFRESH, 0, R.string.action_refresh).setIcon(obtainIcon(R.attr.actionRefresh))
			.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
	menu.add(0, OPTIONS_MENU_SEARCH, 0, R.string.action_search)
			.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
	menu.add(0, OPTIONS_MENU_CATALOG, 0, R.string.action_catalog);
	menu.add(0, OPTIONS_MENU_PAGES, 0, R.string.action_pages);
	menu.add(0, OPTIONS_MENU_ARCHIVE, 0, R.string.action_archive_view);
	menu.add(0, OPTIONS_MENU_NEW_THREAD, 0, R.string.action_new_thread);
	menu.addSubMenu(0, OPTIONS_MENU_APPEARANCE, 0, R.string.action_appearance);
	menu.add(0, OPTIONS_MENU_ADD_TO_FAVORITES_TEXT, 0, R.string.action_add_to_favorites);
	menu.add(0, OPTIONS_MENU_REMOVE_FROM_FAVORITES_TEXT, 0, R.string.action_remove_from_favorites);
	menu.add(0, OPTIONS_MENU_ADD_TO_FAVORITES_ICON, 0, R.string.action_add_to_favorites)
			.setIcon(obtainIcon(R.attr.actionAddToFavorites)).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
	menu.add(0, OPTIONS_MENU_REMOVE_FROM_FAVORITES_ICON, 0, R.string.action_remove_from_favorites)
			.setIcon(obtainIcon(R.attr.actionRemoveFromFavorites)).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
	menu.add(0, OPTIONS_MENU_MAKE_HOME_PAGE, 0, R.string.action_make_home_page);
}
 
Example 3
Source File: IgnoreSetting.java    From MemoryCleaner with Apache License 2.0 6 votes vote down vote up
@Override public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_ignore_setting, menu);
    SubMenu subMenu = menu.addSubMenu(GROUP_ID, BASE_ID, 0, "排序");
    subMenu.setIcon(R.drawable.ic_sort_white_24dp);
    subMenu.add(GROUP_ID + 1, BASE_ID + 1, 0, "应用名");
    subMenu.add(GROUP_ID + 1, BASE_ID + 2, 1, "选中");
    subMenu.add(GROUP_ID + 2, BASE_ID + 3, 2, "降序")
           .setCheckable(true)
           .setChecked(true);
    subMenu.setGroupCheckable(GROUP_ID + 1, true, true);
    mMenuItem = menu.findItem(R.id.allcheck);
    ActionItemBadge.update(this, mMenuItem, FontAwesome.Icon.faw_check,
            ActionItemBadge.BadgeStyles.DARK_GREY, 0);
    return true;
}
 
Example 4
Source File: MemoryClean.java    From MemoryCleaner with Apache License 2.0 6 votes vote down vote up
@Override public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_memory_clean, menu);
    SubMenu subMenu = menu.addSubMenu(GROUP_ID, BASE_ID, 0, "排序");
    subMenu.setIcon(R.drawable.ic_sort_white_24dp);
    subMenu.add(GROUP_ID + 1, BASE_ID + 1, 0, "应用名");
    subMenu.add(GROUP_ID + 1, BASE_ID + 2, 1, "大小");
    subMenu.add(GROUP_ID + 1, BASE_ID + 3, 2, "选中");
    subMenu.add(GROUP_ID + 2, BASE_ID + 4, 3, "降序")
           .setCheckable(true)
           .setChecked(true);
    subMenu.setGroupCheckable(GROUP_ID + 1, true, true);
    mMenuItem = menu.findItem(R.id.allcheck);
    ActionItemBadge.update(this, mMenuItem, FontAwesome.Icon.faw_check,
            ActionItemBadge.BadgeStyles.DARK_GREY, 0);
    return true;
}
 
Example 5
Source File: VectorMapSampleBaseActivity.java    From hellomap3d-android with MIT License 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {

	Menu langMenu = menu.addSubMenu("Language");

	addLanguageMenuOption(langMenu, "English", "en");
	addLanguageMenuOption(langMenu, "German",  "de");
	addLanguageMenuOption(langMenu, "Spanish",  "es");
	addLanguageMenuOption(langMenu, "Italian",  "it");
	addLanguageMenuOption(langMenu, "French",  "fr");
	addLanguageMenuOption(langMenu, "Russian", "ru");
	addLanguageMenuOption(langMenu, "Chinese", "zh");

	Menu styleMenu = menu.addSubMenu("Style");

	addStyleMenuOption(styleMenu, "Basic", "basic");
	addStyleMenuOption(styleMenu, "NutiBright 2D", MAIN_STYLE + ":default");
	addStyleMenuOption(styleMenu, "Nutiteq Dark", MAIN_STYLE + ":nutiteq_dark");
	addStyleMenuOption(styleMenu, "Nutiteq Grey", MAIN_STYLE + ":nutiteq_grey");
	addStyleMenuOption(styleMenu, "NutiBright 3D", "nutibright3d");
	addStyleMenuOption(styleMenu, "Loose Leaf", "looseleaf");

	return true;
}
 
Example 6
Source File: PostsPage.java    From Dashchan with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu) {
	menu.add(0, OPTIONS_MENU_ADD_POST, 0, R.string.action_add_post).setIcon(obtainIcon(R.attr.actionAddPost))
			.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
	menu.add(0, OPTIONS_MENU_SEARCH, 0, R.string.action_search);
	menu.add(0, OPTIONS_MENU_GALLERY, 0, R.string.action_gallery);
	menu.add(0, OPTIONS_MENU_SELECT, 0, R.string.action_select);
	menu.add(0, OPTIONS_MENU_REFRESH, 0, R.string.action_refresh).setIcon(obtainIcon(R.attr.actionRefresh))
			.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
	menu.addSubMenu(0, OPTIONS_MENU_APPEARANCE, 0, R.string.action_appearance);
	SubMenu threadOptions = menu.addSubMenu(0, OPTIONS_MENU_THREAD_OPTIONS, 0, R.string.action_thread_options);
	menu.add(0, OPTIONS_MENU_ADD_TO_FAVORITES_TEXT, 0, R.string.action_add_to_favorites);
	menu.add(0, OPTIONS_MENU_REMOVE_FROM_FAVORITES_TEXT, 0, R.string.action_remove_from_favorites);
	menu.add(0, OPTIONS_MENU_ADD_TO_FAVORITES_ICON, 0, R.string.action_add_to_favorites)
			.setIcon(obtainIcon(R.attr.actionAddToFavorites)).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
	menu.add(0, OPTIONS_MENU_REMOVE_FROM_FAVORITES_ICON, 0, R.string.action_remove_from_favorites)
			.setIcon(obtainIcon(R.attr.actionRemoveFromFavorites)).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
	menu.add(0, OPTIONS_MENU_OPEN_ORIGINAL_THREAD, 0, R.string.action_open_the_original);
	menu.add(0, OPTIONS_MENU_ARCHIVE, 0, R.string.action_archive_add);

	threadOptions.add(0, THREAD_OPTIONS_MENU_RELOAD, 0, R.string.action_reload);
	threadOptions.add(0, THREAD_OPTIONS_MENU_AUTO_REFRESH, 0, R.string.action_auto_refresh).setCheckable(true);
	threadOptions.add(0, THREAD_OPTIONS_MENU_HIDDEN_POSTS, 0, R.string.action_hidden_posts);
	threadOptions.add(0, THREAD_OPTIONS_MENU_CLEAR_DELETED, 0, R.string.action_clear_deleted);
	threadOptions.add(0, THREAD_OPTIONS_MENU_SUMMARY, 0, R.string.action_summary);
}
 
Example 7
Source File: HomeActivity.java    From android-notepad with MIT License 6 votes vote down vote up
public void inflateNavigationMenus(int checkedItemId){
	Menu menu = mNavigationView.getMenu();
	menu.clear();
	menu
			.add(Menu.NONE, ALL_NOTES_MENU_ID, Menu.NONE, "Notes")
			.setIcon(R.drawable.ic_note_white_24dp)
			.setChecked(checkedItemId == ALL_NOTES_MENU_ID);
	final SubMenu subMenu = menu.addSubMenu("Folders");
	latestFolders = FoldersDAO.getLatestFolders();
	for (Folder folder : latestFolders){
		subMenu
				.add(Menu.NONE, folder.getId(), Menu.NONE, folder.getName())
				.setIcon(R.drawable.ic_folder_black_24dp)
				.setChecked(folder.getId() == checkedItemId);
	}
	menu
			.add(Menu.NONE, EDIT_FOLDERS_MENU_ID, Menu.NONE, "Create or edit folders")
			.setIcon(R.drawable.ic_add_white_24dp);
	SubMenu backupSubMenu = menu.addSubMenu("Backup and restore");
	backupSubMenu
			.add(Menu.NONE, SAVE_DATABASE_MENU_ID, Menu.NONE, "Backup data")
			.setIcon(R.drawable.ic_save_white_24dp);
	backupSubMenu
			.add(Menu.NONE, IMPORT_DATABASE_MENU_ID, Menu.NONE, "Restore data")
			.setIcon(R.drawable.ic_restore_white_24dp);
}
 
Example 8
Source File: OptionsMenuUtility.java    From RedReader with GNU General Public License v3.0 6 votes vote down vote up
private static void addAllUserCommentSorts(final AppCompatActivity activity, final Menu menu, final boolean icon) {

		final SubMenu sortComments = menu.addSubMenu(R.string.options_sort_comments);

		if(icon) {
			sortComments.getItem().setIcon(R.drawable.ic_sort_dark);
			sortComments.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
		}

		addSort(activity, sortComments, R.string.sort_comments_hot, UserCommentListingURL.Sort.HOT);
		addSort(activity, sortComments, R.string.sort_comments_new, UserCommentListingURL.Sort.NEW);
		addSort(activity, sortComments, R.string.sort_comments_controversial, UserCommentListingURL.Sort.CONTROVERSIAL);

		final SubMenu sortCommentsTop = sortComments.addSubMenu(R.string.sort_comments_top);

		addSort(activity, sortCommentsTop, R.string.sort_posts_top_hour, UserCommentListingURL.Sort.TOP_HOUR);
		addSort(activity, sortCommentsTop, R.string.sort_posts_top_today, UserCommentListingURL.Sort.TOP_DAY);
		addSort(activity, sortCommentsTop, R.string.sort_posts_top_week, UserCommentListingURL.Sort.TOP_WEEK);
		addSort(activity, sortCommentsTop, R.string.sort_posts_top_month, UserCommentListingURL.Sort.TOP_MONTH);
		addSort(activity, sortCommentsTop, R.string.sort_posts_top_year, UserCommentListingURL.Sort.TOP_YEAR);
		addSort(activity, sortCommentsTop, R.string.sort_posts_top_all, UserCommentListingURL.Sort.TOP_ALL);
	}
 
Example 9
Source File: NavigationActivity.java    From KernelAdiutor with GNU General Public License v3.0 5 votes vote down vote up
private void appendFragments(boolean setShortcuts) {
    mActualFragments.clear();
    Menu menu = mNavigationView.getMenu();
    menu.clear();

    SubMenu lastSubMenu = null;
    for (NavigationFragment navigationFragment : mFragments) {
        Class<? extends Fragment> fragmentClass = navigationFragment.mFragmentClass;
        int id = navigationFragment.mId;

        Drawable drawable = ContextCompat.getDrawable(this,
                Utils.DONATED
                        && AppSettings.isSectionIcons(this)
                        && navigationFragment.mDrawable != 0 ? navigationFragment.mDrawable :
                        R.drawable.ic_blank);

        if (fragmentClass == null) {
            lastSubMenu = menu.addSubMenu(id);
            mActualFragments.put(id, null);
        } else if (AppSettings.isFragmentEnabled(fragmentClass, this)) {
            MenuItem menuItem = lastSubMenu == null ? menu.add(0, id, 0, id) :
                    lastSubMenu.add(0, id, 0, id);
            menuItem.setIcon(drawable);
            menuItem.setCheckable(true);
            if (mSelection != 0) {
                mNavigationView.setCheckedItem(mSelection);
            }
            mActualFragments.put(id, fragmentClass);
        }
    }
    if (setShortcuts) {
        setShortcuts();
    }
}
 
Example 10
Source File: PlayerActivity.java    From 4pdaClient-plus with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    SubMenu subMenu;
    if (parseResult!=null&&parseResult.getQualities().size() > 1) {

        subMenu = menu.addSubMenu(R.string.quality);

        subMenu.getItem().setIcon(R.drawable.settings_white);
        subMenu.getItem().setTitle(R.string.quality);


        for (final Quality format : parseResult.getQualities()) {
            subMenu.add(format.getTitle()).setOnMenuItemClickListener(menuItem -> {
                String path = VideoItem.getFilePath(format.getFileName());

                getMainActivity().playVideo(parseResult, path);
                return true;
            });
        }
        subMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    }
    subMenu = menu.addSubMenu(R.string.link).setIcon(R.drawable.share_variant);

    addUrlMenu(getActivity(), subMenu, getMainActivity().getPlayedRequestUrl());
    subMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
}
 
Example 11
Source File: UserBoardsPage.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu) {
	menu.add(0, OPTIONS_MENU_SEARCH, 0, R.string.action_filter)
			.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
	menu.add(0, OPTIONS_MENU_REFRESH, 0, R.string.action_refresh).setIcon(obtainIcon(R.attr.actionRefresh))
			.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
	menu.addSubMenu(0, OPTIONS_MENU_APPEARANCE, 0, R.string.action_appearance);
}
 
Example 12
Source File: SearchPage.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu) {
	menu.add(0, OPTIONS_MENU_SEARCH, 0, R.string.action_search).setIcon(obtainIcon(R.attr.actionSearch))
			.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
	menu.add(0, OPTIONS_MENU_REFRESH, 0, R.string.action_refresh);
	menu.add(0, OPTIONS_MENU_GROUP, 0, R.string.action_group).setCheckable(true);
	menu.addSubMenu(0, OPTIONS_MENU_APPEARANCE, 0, R.string.action_appearance);
}
 
Example 13
Source File: BoardsPage.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu) {
	PageHolder pageHolder = getPageHolder();
	menu.add(0, OPTIONS_MENU_SEARCH, 0, R.string.action_filter)
			.setShowAsAction(MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
	menu.add(0, OPTIONS_MENU_REFRESH, 0, R.string.action_refresh).setIcon(obtainIcon(R.attr.actionRefresh))
			.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
	menu.addSubMenu(0, OPTIONS_MENU_APPEARANCE, 0, R.string.action_appearance);
	menu.add(0, OPTIONS_MENU_MAKE_HOME_PAGE, 0, R.string.action_make_home_page);
	menu.findItem(OPTIONS_MENU_MAKE_HOME_PAGE).setVisible(Preferences.getDefaultBoardName(pageHolder.chanName)
			!= null);
}
 
Example 14
Source File: SettingsMenu.java    From GestureViews with Apache License 2.0 5 votes vote down vote up
private <T> void addSubMenu(Menu menu, T[] items, T selected, @StringRes int titleId) {
    SubMenu sub = menu.addSubMenu(titleId);
    sub.setGroupCheckable(Menu.NONE, true, true);

    for (int i = 0; i < items.length; i++) {
        MenuItem item = sub.add(Menu.NONE, titleId, i, items[i].toString());
        item.setCheckable(true);
        item.setChecked(items[i] == selected);
    }
}
 
Example 15
Source File: ReputationFragment.java    From ForPDA with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void addBaseToolbarMenu(Menu menu) {
    super.addBaseToolbarMenu(menu);
    SubMenu subMenu = menu.addSubMenu(R.string.sorting_title);
    subMenu.getItem().setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
    subMenu.getItem().setIcon(App.getVecDrawable(getContext(), R.drawable.ic_toolbar_sort));
    descSortMenuItem = subMenu.add(R.string.sorting_desc).setOnMenuItemClickListener(menuItem -> {
        data.setSort(Reputation.SORT_DESC);
        loadData();
        return false;
    });
    ascSortMenuItem = subMenu.add(R.string.sorting_asc).setOnMenuItemClickListener(menuItem -> {
        data.setSort(Reputation.SORT_ASC);
        loadData();
        return false;
    });
    repModeMenuItem = menu.add(getString(data.getMode().equals(Reputation.MODE_FROM) ? R.string.reputation_mode_from : R.string.reputation_mode_to))
            .setOnMenuItemClickListener(item -> {
                if (data.getMode().equals(Reputation.MODE_FROM))
                    data.setMode(Reputation.MODE_TO);
                else
                    data.setMode(Reputation.MODE_FROM);
                loadData();
                return false;
            });
    upRepMenuItem = menu.add(R.string.increase)
            .setOnMenuItemClickListener(item -> {
                changeReputation(true);
                return false;
            });
    downRepMenuItem = menu.add(R.string.decrease)
            .setOnMenuItemClickListener(item -> {
                changeReputation(false);
                return false;
            });
    refreshToolbarMenuItems(false);
}
 
Example 16
Source File: ConnectFragment.java    From zephyr with MIT License 5 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    ZephyrApplication.getApplicationComponent().inject(this);

    analyticsManager.logEvent(ZephyrEvent.Action.OPEN_CONNECTION_MENU);

    // Skip to entering code is QR scanning isn't enabled
    if (!configManager.isQrCodeScanningEnabled()) {
        logger.log(LogLevel.INFO, LOG_TAG, "QR code scanning is disabled, skipping to entering code.");
        JoinCodeFragment joinCodeFragment = new JoinCodeFragment();
        joinCodeFragment.show(getParentFragmentManager(), joinCodeFragment.getTag());
        dismiss();
    }

    mNavigationView.setNavigationItemSelectedListener(this);
    View navigationHeaderContainer = mNavigationView.getRootView().findViewById(R.id.navigation_header_container);
    if (navigationHeaderContainer != null) {
        navigationHeaderContainer.setVisibility(View.GONE);
    }

    Menu menu = mNavigationView.getMenu();
    SubMenu subMenu = menu.addSubMenu(R.string.menu_connect_discovered_servers);
    discoveryManager.getDiscoveredServers().observe(getViewLifecycleOwner(), discoveredServers -> {
        subMenu.clear();
        for (DiscoveredServer discoveredServer : discoveredServers) {
            String hostName = StringUtils.isNullOrEmpty(discoveredServer.getHostName())
                    ? getString(R.string.menu_connect_discovered_server_default_name)
                    : discoveredServer.getHostName();
            MenuItem menuItem = subMenu.add(hostName + " (" + discoveredServer.getIpAddress() + ")");
            menuItem.setOnMenuItemClickListener(item -> {
                connectToDiscoveredServer(discoveredServer);
                return true;
            });
        }
    });
}
 
Example 17
Source File: NavigationActivity.java    From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 5 votes vote down vote up
private void appendFragments(boolean setShortcuts) {
    mActualFragments.clear();
    Menu menu = mNavigationView.getMenu();
    menu.clear();

    SubMenu lastSubMenu = null;
    for (NavigationFragment navigationFragment : mFragments) {
        Class<? extends Fragment> fragmentClass = navigationFragment.mFragmentClass;
        int id = navigationFragment.mId;

        Drawable drawable = ContextCompat.getDrawable(this,
                    AppSettings.isSectionIcons(this)
                    && navigationFragment.mDrawable != 0 ? navigationFragment.mDrawable :
                    R.drawable.ic_blank);

        if (fragmentClass == null) {
            lastSubMenu = menu.addSubMenu(id);
            mActualFragments.put(id, null);
        } else if (AppSettings.isFragmentEnabled(fragmentClass, this)) {
            MenuItem menuItem = lastSubMenu == null ? menu.add(0, id, 0, id) :
                    lastSubMenu.add(0, id, 0, id);
            menuItem.setIcon(drawable);
            menuItem.setCheckable(true);
            if (mSelection != 0) {
                mNavigationView.setCheckedItem(mSelection);
            }
            mActualFragments.put(id, fragmentClass);
        }
    }
    if (setShortcuts) {
        setShortcuts();
    }
}
 
Example 18
Source File: ShadowSupportMenuInflater.java    From open with GNU General Public License v3.0 5 votes vote down vote up
private void addChildrenInGroup(MenuNode source, int groupId, Menu root) {
    for (MenuNode child : source.getChildren()) {
        String name = child.getName();
        RoboAttributeSet attributes =
                shadowOf(context).createAttributeSet(child.getAttributes(), null);
        if (strictI18n) {
            attributes.validateStrictI18n();
        }
        if (name.equals("item")) {
            if (child.isSubMenuItem()) {
                SubMenu sub = root.addSubMenu(groupId,
                        attributes.getAttributeResourceValue(ANDROID_NS, "id", 0),
                        0, attributes.getAttributeValue(ANDROID_NS, "title"));
                MenuNode subMenuNode = child.getChildren().get(0);
                addChildrenInGroup(subMenuNode, groupId, sub);
            } else {
                String menuItemTitle = attributes.getAttributeValue(ANDROID_NS, "title");
                if (isFullyQualifiedName(menuItemTitle)) {
                    menuItemTitle = getStringResourceValue(attributes);
                }

                int orderInCategory =
                        attributes.getAttributeIntValue(ANDROID_NS, "orderInCategory", 0);
                int menuItemId = attributes.getAttributeResourceValue(ANDROID_NS, "id", 0);
                MenuItem item = root.add(groupId, menuItemId, orderInCategory, menuItemTitle);

                addActionViewToItem(item, attributes);
            }
        } else if (name.equals("group")) {
            int newGroupId = attributes.getAttributeResourceValue(ANDROID_NS, "id", 0);
            addChildrenInGroup(child, newGroupId, root);
        }
    }
}
 
Example 19
Source File: PlayActivity.java    From shortyz with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (puz != null && !puz.isUpdatable()) {
        MenuItem showItem = menu.add(
                this.showErrors ? "Hide Errors" : "Show Errors").setIcon(
                android.R.drawable.ic_menu_view);
        if (ShortyzApplication.isTabletish(metrics)) {
            utils.onActionBarWithText(showItem);
        }

        SubMenu reveal = menu.addSubMenu("Reveal").setIcon(
                android.R.drawable.ic_menu_view);
        reveal.add(createSpannableForMenu("Letter")).setTitleCondensed("Letter");
        reveal.add(createSpannableForMenu("Word")).setTitleCondensed("Word");
        reveal.add(createSpannableForMenu("Errors")).setTitleCondensed("Errors");
        reveal.add(createSpannableForMenu("Puzzle")).setTitleCondensed("Puzzle");
        if (ShortyzApplication.isTabletish(metrics)) {
            utils.onActionBarWithText(reveal);
        }
    } else {
        menu.add("Show Errors").setEnabled(false)
                .setIcon(android.R.drawable.ic_menu_view);
        menu.add("Reveal").setIcon(android.R.drawable.ic_menu_view)
                .setEnabled(false);
    }

    menu.add("Clues").setIcon(android.R.drawable.ic_menu_agenda);
    Menu clueSize = menu.addSubMenu("Clue Text Size");
    clueSize.add(createSpannableForMenu("Small")).setTitleCondensed("Small");
    clueSize.add(createSpannableForMenu("Medium")).setTitleCondensed("Medium");
    clueSize.add(createSpannableForMenu("Large")).setTitleCondensed("Large");
    Menu zoom = menu.addSubMenu("Zoom");
    zoom.add(createSpannableForMenu("Zoom In")).setTitleCondensed("Zoom In");

    if (getRenderer() != null && getRenderer().getScale() < getRenderer().getDeviceMaxScale())
        zoom.add(createSpannableForMenu("Zoom In Max")).setTitleCondensed("Zoom In Max");

    zoom.add(createSpannableForMenu("Zoom Out")).setTitleCondensed("Zoom Out");
    zoom.add(createSpannableForMenu("Fit to Screen")).setTitleCondensed("Fit to Screen");
    zoom.add(createSpannableForMenu("Zoom Reset")).setTitleCondensed("Zoom Reset");
    menu.add("Info").setIcon(android.R.drawable.ic_menu_info_details);
    menu.add("Help").setIcon(android.R.drawable.ic_menu_help);
    menu.add("Settings").setIcon(android.R.drawable.ic_menu_preferences);

    return true;
}
 
Example 20
Source File: MenuHandler.java    From divide with Apache License 2.0 4 votes vote down vote up
public TopLevelMenu(int group, String text, Menu menu){
    this.subMenu = menu.addSubMenu(group, 1, 0, text);
    this.group = group;
}