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


Java SubMenu.add方法代码示例

本文整理汇总了Java中android.view.SubMenu.add方法的典型用法代码示例。如果您正苦于以下问题:Java SubMenu.add方法的具体用法?Java SubMenu.add怎么用?Java SubMenu.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.SubMenu的用法示例。


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

示例1: onCreateOptionsMenu

import android.view.SubMenu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	menu.add(0, 0, 0, "Local").setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

	SubMenu subDebug = menu.addSubMenu(100, 100, 100, "Dev tools...");
	subDebug.add(2, 2, 2, "TEST!");
	subDebug.add(8, 8, 8, "Override inet address");
	subDebug.add(9, 9, 9, "Save logs");

	SubMenu subDomain = menu.addSubMenu(101, 101, 101, "Domain...");
	subDomain.add(3, 3, 3, "Save our world now");

	SubMenu subDb = menu.addSubMenu(102, 102, 102, "Database...");
	subDb.add(5, 5, 5, "Import file to db");
	subDb.add(6, 6, 6, "Export from db");

	menu.add(7, 7, 7, "Kill myself with pleasure");
	return true;
}
 
开发者ID:nmud,项目名称:nmud-demo,代码行数:20,代码来源:MainActivity.java

示例2: onCreateOptionsMenu

import android.view.SubMenu; //导入方法依赖的package包/类
@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;
}
 
开发者ID:towavephone,项目名称:MemoryCleaner,代码行数:17,代码来源:IgnoreSetting.java

示例3: onCreateOptionsMenu

import android.view.SubMenu; //导入方法依赖的package包/类
@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;
}
 
开发者ID:towavephone,项目名称:MemoryCleaner,代码行数:18,代码来源:MemoryClean.java

示例4: onCreateOptionsMenu

import android.view.SubMenu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    menu.add(MENU_GROUP_SEARCH, MENU_REFRESH, Menu.NONE, R.string.refresh)
            .setIcon(R.drawable.ic_menu_refresh);
    menu.add(Menu.NONE, MENU_SHOUT, Menu.NONE, R.string.shout_action_label)
            .setIcon(R.drawable.ic_menu_shout);

    SubMenu menuMore = menu.addSubMenu(Menu.NONE, MENU_MORE, Menu.NONE, "More");
    menuMore.setIcon(android.R.drawable.ic_menu_more);
    for (Map.Entry<Integer, String> it : mMenuMoreSubitems.entrySet()) {
        menuMore.add(it.getValue());
    }
    
    MenuUtils.addPreferencesToMenu(this, menu);
 
    return true;
}
 
开发者ID:Kamshak,项目名称:foursquared,代码行数:19,代码来源:FriendsActivity.java

示例5: setupNavMenu

import android.view.SubMenu; //导入方法依赖的package包/类
/**
 * Setups the navigation drawer's menu to include the given collection of subreddits.
 * The subreddit portion of this menu is rebuilt each time.
 *
 * @param subreddits the collection of subreddits to add to the menu
 */
private void setupNavMenu(Collection<String> subreddits) {
    NavigationView mNavView = (NavigationView) findViewById(R.id.nav_view);
    if (subreddits.isEmpty() || mNavView == null) return;
    Menu menu = mNavView.getMenu();
    menu.removeGroup(SUBREDDIT_MENU_GRP);
    SubMenu subMenu = menu.addSubMenu(SUBREDDIT_MENU_GRP, Menu.NONE, Menu.NONE, "Subreddit");
    for (String subreddit : subreddits) {
        subMenu.add(SUBREDDIT_MENU_GRP, Menu.NONE, Menu.NONE, subreddit);
    }
    subMenu.setGroupCheckable(SUBREDDIT_MENU_GRP, true, true);
    mNavView.setNavigationItemSelectedListener(item -> {
        selectNavItem(item);
        return true;
    });
}
 
开发者ID:JotraN,项目名称:Reader,代码行数:22,代码来源:MainActivity.java

示例6: onCreateOptionsMenu

import android.view.SubMenu; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
	super.onCreateOptionsMenu(menu, inflater);

	MenuItem filterItem = menu.findItem(R.id.songbook_filter_category);
	if (null != filterItem) {
		SubMenu subMenu = filterItem.getSubMenu();
		subMenu.clear();

		if (null != mSongbook) {
			subMenu.add(Menu.NONE, MENU_CLEAR_FILTER_ID, Menu.NONE, R.string.songbook_show_all);

			List<String> categories = mSongbook.categories();
			for (int i = 0; i < categories.size(); i++) {
				subMenu.add(MENU_CATEGORIES_ID, MENU_CATEGORIES_ID + i, Menu.NONE, categories.get(i));
			}
		}
	}
}
 
开发者ID:wsv-accidis,项目名称:in-sangbok,代码行数:20,代码来源:SongbookFragment.java

示例7: onActionItemClicked

import android.view.SubMenu; //导入方法依赖的package包/类
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
    if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, actionMode, menuItem);

    switch (menuItem.getItemId()) {
        case R.id.query_cab_schedule:
            displayScheduleTimestampDialog(R.id.query_cab_schedule, mSelection.getIds());
            break;

        case R.id.query_cab_state:
            /* Add all known states to menu. */
            SubMenu subMenu = menuItem.getSubMenu();
            if (subMenu != null) {
                subMenu.clear();
                for (String str: new NoteStateSpinner(getActivity(), null).getValues()) {
                    subMenu.add(STATE_ITEM_GROUP, Menu.NONE, Menu.NONE, str);
                }
            }
            break;

        default:
            /* Click on one of the state keywords. */
            if (menuItem.getGroupId() == STATE_ITEM_GROUP) {
                if (mListener != null) {
                    mListener.onStateChangeRequest(mSelection.getIds(), menuItem.getTitle().toString());
                }
                return true;
            }

            return false; // Not handled.
    }

    return true; // Handled.
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:35,代码来源:SearchFragment.java

示例8: onActionItemClicked

import android.view.SubMenu; //导入方法依赖的package包/类
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
    if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG, actionMode, menuItem);
    TreeSet<Long> selectionIds;
    switch (menuItem.getItemId()) {
        case R.id.query_cab_schedule:
            selectionIds = originalSelectedIds();
            if (!selectionIds.isEmpty()) {
                displayScheduleTimestampDialog(R.id.query_cab_schedule, selectionIds);
            }
            break;

        case R.id.query_cab_state:
            /* Add all known states to menu. */
            SubMenu subMenu = menuItem.getSubMenu();
            if (subMenu != null) {
                subMenu.clear();
                for (String str: new NoteStateSpinner(getActivity(), null).getValues()) {
                    subMenu.add(STATE_ITEM_GROUP, Menu.NONE, Menu.NONE, str);
                }
            }
            break;

        default:
            /* Click on one of the state keywords. */
            if (menuItem.getGroupId() == STATE_ITEM_GROUP) {
                if (mListener != null) {
                    selectionIds = originalSelectedIds();
                    if (!selectionIds.isEmpty()) {
                        mListener.onStateChangeRequest(selectionIds, menuItem.getTitle().toString());
                    }
                }
                return true;
            }

            return false; // Not handled.
    }

    return true; // Handled.
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:41,代码来源:AgendaFragment.java

示例9: appendFragments

import android.view.SubMenu; //导入方法依赖的package包/类
private void appendFragments(boolean setShortcuts) {
    sActualFragments.clear();
    Menu menu = mNavigationView.getMenu();
    menu.clear();

    SubMenu lastSubMenu = null;
    for (NavigationFragment navigationFragment : sFragments) {
        Fragment fragment = navigationFragment.mFragment;
        int id = navigationFragment.mId;

        Drawable drawable = ContextCompat.getDrawable(this,
                Utils.DONATED
                        && Prefs.getBoolean("section_icons", true, this)
                        && navigationFragment.mDrawable != 0 ? navigationFragment.mDrawable :
                        R.drawable.ic_blank);

        if (fragment == null) {
            lastSubMenu = menu.addSubMenu(id);
            sActualFragments.put(id, null);
        } else if (Prefs.getBoolean(fragment.getClass().getSimpleName() + "_enabled",
                true, 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);
            }
            sActualFragments.put(id, fragment);
        }
    }
    if (setShortcuts) {
        setShortcuts();
    }
}
 
开发者ID:morogoku,项目名称:MTweaks-KernelAdiutorMOD,代码行数:36,代码来源:NavigationActivity.java

示例10: appendFragments

import android.view.SubMenu; //导入方法依赖的package包/类
private void appendFragments(boolean setShortcuts) {
    sActualFragments.clear();
    Menu menu = mNavigationView.getMenu();
    menu.clear();

    SubMenu lastSubMenu = null;
    for (NavigationFragment navigationFragment : sFragments) {
        Fragment fragment = navigationFragment.mFragment;
        int id = navigationFragment.mId;

        Drawable drawable = ContextCompat.getDrawable(this,
                Utils.DONATED
                        && Prefs.getBoolean("section_icons", false, this)
                        && navigationFragment.mDrawable != 0 ? navigationFragment.mDrawable :
                        R.drawable.ic_blank);

        if (fragment == null) {
            lastSubMenu = menu.addSubMenu(id);
            sActualFragments.put(id, null);
        } else if (Prefs.getBoolean(fragment.getClass().getSimpleName() + "_enabled",
                true, 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);
            }
            sActualFragments.put(id, fragment);
        }
    }
    if (setShortcuts) {
        setShortcuts();
    }
}
 
开发者ID:AyushR1,项目名称:KernelAdiutor-Mod,代码行数:36,代码来源:NavigationActivity.java

示例11: onCreateOptionsMenu

import android.view.SubMenu; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.user_profile, menu);

    if (mUser != null && TextUtils.equals(mAccount.screenName(), mUser.getScreenName())) {
        menu.findItem(R.id.menu_direct).setVisible(false);
        menu.findItem(R.id.menu_reply).setVisible(false);
        menu.findItem(R.id.menu_spam).setVisible(false);
        menu.findItem(R.id.menu_block).setVisible(false);
        menu.findItem(R.id.menu_follow).setVisible(false);
    }

    List<UserList> userLists = mUserListsModel.lists().toBlocking().first();
    if (mUser != null && !userLists.isEmpty()) {
        final SubMenu listSubMenu = menu.addSubMenu(R.string.add_to_list);
        for (UserList userList : userLists) {
            listSubMenu.add(0, (int) userList.listId(), Menu.NONE, userList.name());
        }
    }

    if (mRelationship != null) {
        boolean isFollowing = mRelationship.isSourceFollowingTarget();
        boolean isBlocking = mRelationship.isSourceBlockingTarget();

        menu.findItem(R.id.menu_follow)
                .setIcon(isFollowing ? R.drawable.ic_account_remove : R.drawable.ic_person_add)
                .setTitle(isFollowing ? R.string.unfollow : R.string.follow);

        menu.findItem(R.id.menu_block)
                .setTitle(isBlocking ? R.string.unblock : R.string.block);
    }

    return super.onCreateOptionsMenu(menu);
}
 
开发者ID:mecid,项目名称:robird-reborn,代码行数:35,代码来源:UserProfileActivity.java

示例12: makePlaylistMenu

import android.view.SubMenu; //导入方法依赖的package包/类
public static void makePlaylistMenu(Context context, SubMenu sub, int groupdId) {
    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(groupdId, 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(groupdId, Defs.PLAYLIST_SELECTED, 0, cur.getString(1)).setIntent(intent);
                cur.moveToNext();
            }
        }
        if (cur != null) {
            cur.close();
        }
    }
}
 
开发者ID:reyanshmishra,项目名称:Rey-MusicPlayer,代码行数:31,代码来源:MusicUtils.java

示例13: overflowsubmenu

import android.view.SubMenu; //导入方法依赖的package包/类
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();
        }
    }
}
 
开发者ID:reyanshmishra,项目名称:Rey-MusicPlayer,代码行数:31,代码来源:MusicUtils.java

示例14: createModesMenu

import android.view.SubMenu; //导入方法依赖的package包/类
private void createModesMenu(Menu menu) {
    SubMenu modesSubMenu = menu.findItem(R.id.action_modes).getSubMenu();
    IModeInfo[] modeInfoList = mEncoder.getModeInfoList();
    for (IModeInfo modeInfo : modeInfoList) {
        MenuItem item = modesSubMenu.add(modeInfo.getModeName());
        Intent intent = new Intent();
        intent.putExtra(CLASS_NAME, modeInfo.getModeClassName());
        item.setIntent(intent);
    }
}
 
开发者ID:olgamiller,项目名称:SSTVEncoder2,代码行数:11,代码来源:MainActivity.java

示例15: makePlaylistMenuOnline

import android.view.SubMenu; //导入方法依赖的package包/类
/**
 * Same as makePlaylistMenu, but only for online provides
 *
 * @param context The context to use for creating the menu items
 * @param sub     The submenu to add the items to.
 */
public static void makePlaylistMenuOnline(Context context, SubMenu sub) {
    String[] cols = new String[]{MediaStore.Audio.Playlists._ID,
            MediaStore.Audio.Playlists.NAME};
    ContentResolver resolver = context.getContentResolver();
    if (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()) {
                if (cur.getLong(0) == MusicUtils.getPlaylistiD(cur
                        .getString(1))) {
                    Intent intent = new Intent();
                    intent.putExtra("playlist", cur.getLong(0));
                    intent.putExtra("name", cur.getString(1));
                    // if (cur.getInt(0) == mLastPlaylistSelected) {
                    // sub.add(0, MusicBaseActivity.PLAYLIST_SELECTED,
                    // cur.getString(1)).setIntent(intent);
                    // } else {
                    sub.add(1, Defs.PLAYLIST_SELECTED, 0, cur.getString(1))
                            .setIntent(intent);
                    // }
                }
                cur.moveToNext();
            }
        }
        if (cur != null) {
            cur.close();
        }
    }
}
 
开发者ID:89luca89,项目名称:ThunderMusic,代码行数:45,代码来源:MusicUtils.java


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