Java Code Examples for android.view.SubMenu#add()

The following examples show how to use android.view.SubMenu#add() . 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: MainActivity2.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
/**
	 * �����˵�
	 * 
	 * ��дonCreateOptionsMenu
	 * 
	 * ͨ��������ʽ��Ӳ˵���
	 * */
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		//��д Activity �� onCreateOptionsMenu(Menu menu) �������ڷ����ڵ��� Menu ����ķ�������Ӳ˵�����Ӳ˵���
		// ���һ����ͨ�˵�(һ���˵�)
		// groupId,itemId,orderId,title
		MenuItem add_item = menu.add(0, 0x666, 0, "���");
		// ����ͼƬ
		add_item.setIcon(R.drawable.d03);
		// ��ʾ�ڲ˵���
		add_item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
		
		//���������˵�
		SubMenu subMenu = menu.addSubMenu("�ı���С");
		//�����д����IJ˵������ö����˵���ͼƬûʲô����,û��Ӧ��(xml����)
//		subMenu.setHeaderIcon(R.drawable.ic_launcher);
//		subMenu.setIcon(R.drawable.ic_launcher);
		subMenu.add(1, 0x101, 0, "��");
		subMenu.add(1, 0x102, 0, "��");
		subMenu.add(1, 0x103, 0, "С");
		
		return super.onCreateOptionsMenu(menu);
	}
 
Example 3
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 4
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 5
Source File: TilesOverlay.java    From osmdroid with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(final Menu pMenu, final int pMenuIdOffset,
		final MapView pMapView) {
	final SubMenu mapMenu = pMenu.addSubMenu(0, Menu.NONE, Menu.NONE,
			R.string.map_mode).setIcon(R.drawable.ic_menu_mapmode);

	for (int a = 0; a < TileSourceFactory.getTileSources().size(); a++) {
		final ITileSource tileSource = TileSourceFactory.getTileSources().get(a);
		mapMenu.add(MENU_MAP_MODE + pMenuIdOffset, MENU_TILE_SOURCE_STARTING_ID + a
				+ pMenuIdOffset, Menu.NONE, tileSource.name());
	}
	mapMenu.setGroupCheckable(MENU_MAP_MODE + pMenuIdOffset, true, true);

	if (ctx!=null) {
		final String title = ctx.getString(
				pMapView.useDataConnection() ? R.string.set_mode_offline
						: R.string.set_mode_online);
		final Drawable icon = ctx.getResources().getDrawable(R.drawable.ic_menu_offline);
		pMenu.add(0, MENU_OFFLINE + pMenuIdOffset, Menu.NONE, title).setIcon(icon);
		pMenu.add(0, MENU_SNAPSHOT + pMenuIdOffset, Menu.NONE, R.string.snapshot);
		pMenu.add(0, MENU_STATES + pMenuIdOffset, Menu.NONE, R.string.states);
	}
	return true;
}
 
Example 6
Source File: MainActivity.java    From AndroidDemo with MIT License 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    //四个参数的含义:

    // 1.group的id;2.item的id;3.是否排序;4.将要显示的内容
    menu.add(0, 1, 0, "计算机科学与技术");
    menu.add(0, 2, 0, "网络工程");
    menu.add(0, 3, 0, "信息安全");
    menu.add(0, 4, 0, "河北大学艺术学院");
    menu.add(0, 5, 0, "河北大学质检学院");
    SubMenu sub = menu.addSubMenu("子菜单");
    sub.add(0, 5, 0, "子菜单一");
    sub.add(0, 6, 0, "子菜单二");
    sub.add(0, 7, 0, "子菜单三");

    menu.add(1, 6, 0, "河北大学计算机学院");
    menu.add(1, 7, 1, "河北大学电信学院");
    menu.add(1, 8, 5, "河北大学新闻学院");
    menu.add(1, 9, 2, "河北大学艺术学院");
    menu.add(1, 10, 3, "河北大学质检学院");

    return true;
}
 
Example 7
Source File: SearchBookActivity.java    From HaoReader with GNU General Public License v3.0 6 votes vote down vote up
private void initMenu(Menu menu) {
    if (menu == null) return;
    MenuItem item = menu.findItem(R.id.action_outer_source);
    SubMenu subMenu = item.getSubMenu();
    subMenu.removeGroup(R.id.book_source_group);
    if (BookSourceManager.getEnabledCount() > 0) {
        item.setVisible(true);
        item.setEnabled(true);
        MenuItem subItem = subMenu.add(R.id.book_source_group, Menu.NONE, Menu.NONE, R.string.book_all_source);
        if (group == null) {
            subItem.setChecked(true);
        }
        List<String> groupList = BookSourceManager.getEnableGroupList();
        for (String groupName : groupList) {
            subItem = subMenu.add(R.id.book_source_group, Menu.NONE, Menu.NONE, groupName);
            if (TextUtils.equals(group, subItem.getTitle())) {
                subItem.setChecked(true);
            }
        }
        subMenu.setGroupCheckable(R.id.book_source_group, true, true);
    } else {
        item.setVisible(false);
        item.setEnabled(false);
    }
}
 
Example 8
Source File: MusicUtils.java    From Rey-MusicPlayer with Apache License 2.0 5 votes vote down vote up
public static void overflowsubmenu(Context context, SubMenu subMenu) {
    String[] cols = new String[]{
            MediaStore.Audio.Playlists._ID,
            MediaStore.Audio.Playlists.NAME
    };
    ContentResolver resolver = context.getContentResolver();
    if (resolver == null) {
        System.out.println("resolver = null");
    } else {
        String whereclause = MediaStore.Audio.Playlists.NAME + " != ''";
        Cursor cur = resolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                cols, whereclause, null,
                MediaStore.Audio.Playlists.NAME);
        subMenu.clear();
        subMenu.add(0, Defs.NEW_PLAYLIST, 0, R.string.new_playlist);
        if (cur != null && cur.getCount() > 0) {
            //sub.addSeparator(1, 0);
            cur.moveToFirst();
            while (!cur.isAfterLast()) {
                Intent intent = new Intent();
                intent.putExtra("playlist", cur.getLong(0));
                subMenu.add(0, Defs.PLAYLIST_SELECTED, 0, cur.getString(1)).setIntent(intent);
                cur.moveToNext();
            }
        }
        if (cur != null) {
            cur.close();
        }
    }
}
 
Example 9
Source File: MainActivityMenuHelper.java    From SmileEssence with MIT License 5 votes vote down vote up
public static void addItemsToMenu(MainActivity activity, Menu menu) {
    //Post button
    MenuItem postButton = menu.add(Menu.NONE, R.id.actionbar_post, Menu.NONE, activity.getString(R.string.actionbar_post));
    postButton.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    postButton.setIcon(R.drawable.icon_edit);
    //Search button
    //        MenuItem searchButton = menu.add(Menu.NONE, R.id.actionbar_search, Menu.NONE, activity.getString(R.string.actionbar_search));
    //        searchButton.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    //        searchButton.setIcon(R.drawable.icon_search_white);
    //Settings
    SubMenu settings = menu.addSubMenu(Menu.NONE, R.id.actionbar_settings, Menu.NONE, activity.getString(R.string.actionbar_settings));
    settings.setIcon(R.drawable.icon_settings);
    settings.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    settings.add(Menu.NONE, R.id.actionbar_setting, Menu.NONE, activity.getString(R.string.actionbar_setting));
    settings.add(Menu.NONE, R.id.actionbar_edit_templates, Menu.NONE, activity.getString(R.string.actionbar_edit_templates));
    settings.add(Menu.NONE, R.id.actionbar_edit_extraction, Menu.NONE, activity.getString(R.string.actionbar_edit_extraction));
    settings.add(Menu.NONE, R.id.actionbar_edit_commands, Menu.NONE, activity.getString(R.string.actionbar_edit_commands));
    settings.add(Menu.NONE, R.id.actionbar_edit_tabs, Menu.NONE, activity.getString(R.string.actionbar_edit_tabs));
    //External services
    SubMenu services = menu.addSubMenu(Menu.NONE, R.id.actionbar_services, Menu.NONE, activity.getString(R.string.actionbar_services));
    services.setIcon(R.drawable.icon_website);
    services.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    services.add(Menu.NONE, R.id.actionbar_favstar, Menu.NONE, activity.getString(R.string.actionbar_favstar));
    services.add(Menu.NONE, R.id.actionbar_aclog, Menu.NONE, activity.getString(R.string.actionbar_aclog));
    services.add(Menu.NONE, R.id.actionbar_twilog, Menu.NONE, activity.getString(R.string.actionbar_twilog));
    //Report to author
    MenuItem report = menu.add(Menu.NONE, R.id.actionbar_report, Menu.NONE, activity.getString(R.string.actionbar_report));
    report.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    report.setIcon(R.drawable.icon_email);
}
 
Example 10
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 11
Source File: NavigationActivity.java    From SmartPack-Kernel-Manager 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;

        if (fragmentClass == null) {
            lastSubMenu = menu.addSubMenu(id);
            mActualFragments.put(id, null);
        } else if (Prefs.getBoolean(fragmentClass.getSimpleName() + "_enabled",
                true, this)) {
            MenuItem menuItem = lastSubMenu == null ? menu.add(0, id, 0, id) :
                    lastSubMenu.add(0, id, 0, id);
            menuItem.setIcon(ViewUtils.getColoredIcon(Prefs.getBoolean("section_icons", true, this)
                    && navigationFragment.mDrawable != 0 ? navigationFragment.mDrawable : R.drawable.ic_blank, this));
            menuItem.setCheckable(true);
            if (mSelection != 0) {
                mNavigationView.setCheckedItem(mSelection);
            }
            mActualFragments.put(id, fragmentClass);
        }
    }
    if (setShortcuts) {
        setShortcuts();
    }
}
 
Example 12
Source File: MainActivity.java    From Markdown with MIT License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0, 0x1,        0, "Night mode");
    SubMenu sub = menu.addSubMenu(0, 0x2, 0, "Documents");
    sub.add(0, R.raw.dy,       0, "dy");
    sub.add(0, R.raw.hello,    0, "hello");
    sub.add(0, R.raw.mark,     0, "mark");
    sub.add(0, R.raw.sof,      0, "sof");
    sub.add(0, R.raw.test,     0, "test");
    sub.add(0, R.raw.tt,       0, "tt");
    return true;
}
 
Example 13
Source File: MusicUtils.java    From LyricHere with Apache License 2.0 5 votes vote down vote up
/**
 * Fills out the given submenu with items for "new playlist" and
 * any existing playlists. When the user selects an item, the
 * application will receive PLAYLIST_SELECTED with the Uri of
 * the selected playlist, NEW_PLAYLIST if a new playlist
 * should be created, and QUEUE if the "current playlist" was
 * selected.
 *
 * @param context The context to use for creating the menu items
 * @param sub     The submenu to add the items to.
 */
public static void makePlaylistMenu(Context context, SubMenu sub) {
    String[] cols = new String[]{
            MediaStore.Audio.Playlists._ID,
            MediaStore.Audio.Playlists.NAME
    };
    ContentResolver resolver = context.getContentResolver();
    if (resolver == null) {
        System.out.println("resolver = null");
    } else {
        String whereclause = MediaStore.Audio.Playlists.NAME + " != ''";
        Cursor cur = resolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                cols, whereclause, null,
                MediaStore.Audio.Playlists.NAME);
        sub.clear();
        sub.add(1, Defs.QUEUE, 0, R.string.queue);
        sub.add(1, Defs.NEW_PLAYLIST, 0, R.string.new_playlist);
        if (cur != null && cur.getCount() > 0) {
            //sub.addSeparator(1, 0);
            cur.moveToFirst();
            while (!cur.isAfterLast()) {
                Intent intent = new Intent();
                intent.putExtra("playlist", cur.getLong(0));
                sub.add(1, Defs.PLAYLIST_SELECTED, 0, cur.getString(1)).setIntent(intent);
                cur.moveToNext();
            }
        }
        if (cur != null) {
            cur.close();
        }
    }
}
 
Example 14
Source File: ItemsListFragment.java    From tup.dota2recipe with Apache License 2.0 5 votes vote down vote up
/**
 * 创建英雄属性筛选子菜单
 * 
 * @param cMenu
 *            当前菜单项
 * @param cSubMenuKeysId
 *            当前菜单关联的子菜单项资源ID
 * @param menuItemClickListener
 *            创建后的子菜单单击监听
 */
private void createHeroOptionsSubMenu(MenuItem cMenu, int cMenuQueryKeyId,
        int cSubMenuKeysId,
        String[] cSubMenuValues,
        MenuItem.OnMenuItemClickListener menuItemClickListener) {
    if (cMenu == null || menuItemClickListener == null) {
        return;
    }

    final SubMenu cSubMenu = cMenu.getSubMenu();
    final String[] cSubMenuKeys = this.getResources().getStringArray(
            cSubMenuKeysId);
    MenuItem cMenuItem = null;
    int cIndex = 0;
    for (String cMenuKey : cSubMenuKeys) {
        cMenuItem = cSubMenu.add(0, cIndex++, 0, cMenuKey);
        cMenuItem.setOnMenuItemClickListener(menuItemClickListener);
    }

    // 设置菜单默认值
    final String queryKey = menu_items_query_keys[cMenuQueryKeyId];
    if (!queryKey.equals(KEY_MENU_ITEMS_QUERY_ALL) && cSubMenuKeys != null) {
        final int queryValueIndex = Utils.indexOf(cSubMenuValues, queryKey);
        if (queryValueIndex >= 0 && cSubMenuKeys.length > queryValueIndex) {
            cMenu.setTitle(cSubMenuKeys[queryValueIndex]);
        }
    }
}
 
Example 15
Source File: DrawerService.java    From kolabnotes-android with GNU Lesser General Public License v3.0 5 votes vote down vote up
private MenuItem addTag(SubMenu tagMenu, OnDrawerSelectionChangedListener listener, Tag tag){
    SpannableString spannable = new SpannableString(tag.getName());
    if(tag.getColor() != null) {
        spannable.setSpan(new ForegroundColorSpan(Color.parseColor(tag.getColor().getHexcode())), 0, spannable.length(), 0);
    }
    final MenuItem newTagEntry = tagMenu.add(Menu.NONE, tagMenu.size(), Menu.NONE, spannable);
    newTagEntry.setOnMenuItemClickListener(new OnTagItemClickedListener(listener, layout));
    return newTagEntry;
}
 
Example 16
Source File: ViewAsActionProvider.java    From Contacts with MIT License 5 votes vote down vote up
@Override
public void onPrepareSubMenu(SubMenu subMenu)
{
	//super.onPrepareSubMenu(subMenu);
	subMenu.clear();
	
	MenuItem list = subMenu.add("List");
	list.setIcon(R.drawable.ic_action_view_as_list);
	
	MenuItem gridA = subMenu.add("Big grid");
	gridA.setIcon(R.drawable.ic_action_view_as_big_grid);
	
	MenuItem gridB = subMenu.add("Small grid");
	gridB.setIcon(R.drawable.ic_action_view_as_small_grid);
}
 
Example 17
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 18
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 19
Source File: RouteParamFragment.java    From pandora with Apache License 2.0 4 votes vote down vote up
private void initToolbar() {
    getToolbar().getMenu().add(0, 0, RouteParamItem.Type.STRING, "add String extra");
    getToolbar().getMenu().add(0, 0, RouteParamItem.Type.BOOLEAN, "add boolean extra");
    getToolbar().getMenu().add(0, 0, RouteParamItem.Type.INT, "add int extra");
    getToolbar().getMenu().add(0, 0, RouteParamItem.Type.LONG, "add long extra");
    getToolbar().getMenu().add(0, 0, RouteParamItem.Type.FLOAT, "add float extra");
    getToolbar().getMenu().add(0, 0, RouteParamItem.Type.DOUBLE, "add double extra");
    SubMenu subMenu = getToolbar().getMenu().addSubMenu(0, 0, 7, "add flag");
    subMenu.add(R.id.pd_menu_id_1, 0, 0, "FLAG_ACTIVITY_NEW_TASK");
    subMenu.add(R.id.pd_menu_id_1, 0, 1, "FLAG_ACTIVITY_SINGLE_TOP");
    subMenu.add(R.id.pd_menu_id_1, 0, 2, "FLAG_ACTIVITY_CLEAR_TASK");
    subMenu.add(R.id.pd_menu_id_1, 0, 3, "FLAG_ACTIVITY_CLEAR_TOP");
    getToolbar().setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (item.hasSubMenu()) {
                return true;
            } else {
                if (item.getGroupId() == R.id.pd_menu_id_1) {
                    RouteParamItem paramItem = new RouteParamItem(RouteParamItem.Type.NONE);
                    switch (item.getOrder()) {
                        case 0:
                            paramItem.setFlagType(Intent.FLAG_ACTIVITY_NEW_TASK, item.getTitle().toString());
                            break;
                        case 1:
                            paramItem.setFlagType(Intent.FLAG_ACTIVITY_SINGLE_TOP, item.getTitle().toString());
                            break;
                        case 2:
                            paramItem.setFlagType(Intent.FLAG_ACTIVITY_CLEAR_TASK, item.getTitle().toString());
                            break;
                        case 3:
                            paramItem.setFlagType(Intent.FLAG_ACTIVITY_CLEAR_TOP, item.getTitle().toString());
                            break;
                    }
                    getAdapter().insertItem(paramItem);
                } else {
                    getAdapter().insertItem(new RouteParamItem(item.getOrder()));
                }
                return true;
            }
        }
    });
}
 
Example 20
Source File: DrawerService.java    From kolabnotes-android with GNU Lesser General Public License v3.0 4 votes vote down vote up
private MenuItem addNotebook(Context context, SubMenu notebookMenu, OnDrawerSelectionChangedListener listener, Notebook notebook){
    final MenuItem newNotebookEntry = notebookMenu.add(Menu.NONE, notebookMenu.size(), Menu.NONE, notebook.getSummary());
    setNotebookPermissionIcon(context, notebook, newNotebookEntry);
    newNotebookEntry.setOnMenuItemClickListener(new OnNotebookItemClickedListener(listener, layout));
    return newNotebookEntry;
}