android.view.SubMenu Java Examples
The following examples show how to use
android.view.SubMenu.
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: MainDrawerMenu.java From 4pdaClient-plus with Apache License 2.0 | 6 votes |
private void setNavigationItems() { menu = mDrawer.getMenu(); menu.clear(); int itemId = 0; int i = 0; SubMenu subMenu; List<BrickInfo> list; subMenu = menu.addSubMenu(1, 0, 0, R.string.all); list = ListCore.getMainMenuBricks(); for (i = 0; i < list.size(); i++, itemId++) subMenu.add(1, itemId, i, list.get(i).getTitle()).setIcon(list.get(i).getIcon()); subMenu = menu.addSubMenu(2, 0, 0, R.string.other); list = ListCore.getOthersBricks(); for (i = 0; i < list.size(); i++, itemId++) subMenu.add(2, itemId, i, list.get(i).getTitle()).setIcon(list.get(i).getIcon()); }
Example #2
Source File: MainActivity.java From AndroidDemo with MIT License | 6 votes |
@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 #3
Source File: AlbumDetailsActivity.java From RetroMusicPlayer with GNU General Public License v3.0 | 6 votes |
private void setUpSortOrderMenu(@NonNull SubMenu sortOrder) { switch (getSavedSortOrder()) { case AlbumSongSortOrder.SONG_A_Z: sortOrder.findItem(R.id.action_sort_order_title).setChecked(true); break; case AlbumSongSortOrder.SONG_Z_A: sortOrder.findItem(R.id.action_sort_order_title_desc).setChecked(true); break; case AlbumSongSortOrder.SONG_TRACK_LIST: sortOrder.findItem(R.id.action_sort_order_track_list).setChecked(true); break; case AlbumSongSortOrder.SONG_DURATION: sortOrder.findItem(R.id.action_sort_order_artist_song_duration).setChecked(true); break; } }
Example #4
Source File: PlusActionProvider.java From HightCopyWX with Apache License 2.0 | 6 votes |
@Override public void onPrepareSubMenu(SubMenu subMenu) { subMenu.clear(); subMenu.add(Menu.NONE,0,Menu.NONE,mContext.getString(R.string.multi_chat)) .setIcon(R.drawable.multi_chat) .setOnMenuItemClickListener(this); subMenu.add(Menu.NONE,1,Menu.NONE,mContext.getString(R.string.add_friends)) .setIcon(R.drawable.add_friends) .setOnMenuItemClickListener(this); subMenu.add(Menu.NONE,2,Menu.NONE,mContext.getString(R.string.scan)) .setIcon(R.drawable.scan) .setOnMenuItemClickListener(this); subMenu.add(Menu.NONE,3,Menu.NONE,mContext.getString(R.string.pay_money)) .setIcon(R.drawable.pay_money) .setOnMenuItemClickListener(this); subMenu.add(Menu.NONE,4,Menu.NONE,mContext.getString(R.string.help_devise)) .setIcon(R.drawable.help_advise) .setOnMenuItemClickListener(this); }
Example #5
Source File: ConversationActivity.java From Silence with GNU General Public License v3.0 | 6 votes |
private void inflateSubMenuStartSecureSession(Menu menu) { if (Build.VERSION.SDK_INT >= 22 && activeSubscriptions.size() > 1) { menu.findItem(R.id.menu_start_secure_session).setVisible(false); SubMenu startSecureSessionMenu = menu.findItem(R.id.menu_start_secure_session_dual_sim).getSubMenu(); for (SubscriptionInfoCompat subscriptionInfo : activeSubscriptions) { final int subscriptionId = subscriptionInfo.getSubscriptionId(); if (!SessionUtil.hasSession(this, masterSecret, recipients.getPrimaryRecipient().getNumber(), subscriptionId)) { startSecureSessionMenu.add(Menu.NONE, Menu.NONE, Menu.NONE, subscriptionInfo.getDisplayName()) .setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { handleStartSecureSession(subscriptionId); return true; } }); } } } else { menu.findItem(R.id.menu_start_secure_session_dual_sim).setVisible(false); } }
Example #6
Source File: ViewUtils.java From OpenHub with GNU General Public License v3.0 | 6 votes |
public static void selectMenuItem(@NonNull Menu menu, @IdRes int itemId, boolean findSub) { boolean find = false; for (int i = 0; i < menu.size(); i++) { if (!findSub) { menu.getItem(i).setChecked(menu.getItem(i).getItemId() == itemId); } else { if (menu.getItem(i).getItemId() == itemId) { find = true; } } } if (!findSub) { return; } else if (find) { selectMenuItem(menu, itemId, false); } else { for (int i = 0; i < menu.size(); i++) { SubMenu subMenu = menu.getItem(i).getSubMenu(); if(subMenu != null) selectMenuItem(subMenu, itemId, true); } } }
Example #7
Source File: IgnoreSetting.java From MemoryCleaner with Apache License 2.0 | 6 votes |
@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 #8
Source File: MemoryClean.java From MemoryCleaner with Apache License 2.0 | 6 votes |
@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 #9
Source File: MainActivity.java From Kandroid with GNU General Public License v3.0 | 6 votes |
private void populateProjectsMenu() { if (mProjectList == null) { if (BuildConfig.DEBUG) Log.d("Kandroid", "Tried to populate drawer, but mDashboard was null"); return; } SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getBaseContext()); List<KanboardProject> projList = mProjectList; if (preferences.getBoolean("projects_sort_alphabetic", false)) Collections.sort(projList); NavigationView nav = (NavigationView) findViewById(R.id.nav_view); SubMenu projMenu = nav.getMenu().findItem(R.id.projects).getSubMenu(); projMenu.clear(); for (KanboardProject item: projList) projMenu.add(Menu.NONE, item.getId(), Menu.NONE, item.getName()) .setIcon(R.drawable.project); }
Example #10
Source File: ForumFilterProvider.java From BigApp_Discuz_Android with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void onPrepareSubMenu(SubMenu subMenu) { if (replayItem != null) { return; } subMenu.clear(); replayItem = subMenu.add(0, 1, 1, R.string.newly_reply).setIcon(R.drawable.ic_new_replay_checked); publishItem = subMenu.add(0, 2, 2, R.string.newly_publish).setIcon(R.drawable.ic_new_publish_unchecked); if (mListener != null) { replayItem.setOnMenuItemClickListener(mListener); publishItem.setOnMenuItemClickListener(mListener); } }
Example #11
Source File: SearchBookActivity.java From HaoReader with GNU General Public License v3.0 | 6 votes |
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 #12
Source File: MainActivity.java From Loop with Apache License 2.0 | 6 votes |
private void formatMenuItems() { Menu menu = navigationView.getMenu(); for (int i = 0; i < menu.size(); i++) { MenuItem mi = menu.getItem(i); SubMenu subMenu = mi.getSubMenu(); if (subMenu != null && subMenu.size() > 0) { for (int j = 0; j < subMenu.size(); j++) { MenuItem subMenuItem = subMenu.getItem(j); applyFontToMenuItem(subMenuItem); } } applyFontToMenuItem(mi); } }
Example #13
Source File: MainActivity.java From rcloneExplorer with MIT License | 6 votes |
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 #14
Source File: OptionsMenuUtility.java From RedReader with GNU General Public License v3.0 | 6 votes |
private static void addAllCommentSorts(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_best, PostCommentListingURL.Sort.BEST); addSort(activity, sortComments, R.string.sort_comments_hot, PostCommentListingURL.Sort.HOT); addSort(activity, sortComments, R.string.sort_comments_new, PostCommentListingURL.Sort.NEW); addSort(activity, sortComments, R.string.sort_comments_old, PostCommentListingURL.Sort.OLD); addSort(activity, sortComments, R.string.sort_comments_controversial, PostCommentListingURL.Sort.CONTROVERSIAL); addSort(activity, sortComments, R.string.sort_comments_top, PostCommentListingURL.Sort.TOP); addSort(activity, sortComments, R.string.sort_comments_qa, PostCommentListingURL.Sort.QA); }
Example #15
Source File: MicroActivity.java From J2ME-Loader with Apache License 2.0 | 5 votes |
@Override public boolean onPrepareOptionsMenu(Menu menu) { if (current != null) { menu.clear(); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.midlet_displayable, menu); if (current instanceof Canvas) { SubMenu group = menu.getItem(0).getSubMenu(); if (actionBarEnabled) { inflater.inflate(R.menu.midlet_canvas_no_keys2, menu); } else { inflater.inflate(R.menu.midlet_canvas_no_keys, group); } VirtualKeyboard vk = ContextHolder.getVk(); if (vk instanceof FixedKeyboard) { inflater.inflate(R.menu.midlet_canvas_fixed, group); } else if (vk != null) { inflater.inflate(R.menu.midlet_canvas, group); } } for (Command cmd : current.getCommands()) { menu.add(Menu.NONE, cmd.hashCode(), Menu.NONE, cmd.getAndroidLabel()); } } return super.onPrepareOptionsMenu(menu); }
Example #16
Source File: BrowserActivity.java From document-viewer with GNU General Public License v3.0 | 5 votes |
protected void createFileMenu(final ContextMenu menu, final String path) { final BookSettings bs = SettingsManager.getBookSettings(path); final MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.book_menu, menu); menu.setHeaderTitle(path); menu.findItem(R.id.bookmenu_recentgroup).setVisible(bs != null); menu.findItem(R.id.bookmenu_openbookshelf).setVisible(false); menu.findItem(R.id.bookmenu_openbookfolder).setVisible(false); final MenuItem om = menu.findItem(R.id.bookmenu_open); final SubMenu osm = om != null ? om.getSubMenu() : null; if (osm == null) { return; } osm.clear(); final List<Bookmark> list = new ArrayList<Bookmark>(); list.add(new Bookmark(true, getString(R.string.bookmark_start), PageIndex.FIRST, 0, 0)); list.add(new Bookmark(true, getString(R.string.bookmark_end), PageIndex.LAST, 0, 1)); if (bs != null) { if (LengthUtils.isNotEmpty(bs.bookmarks)) { list.addAll(bs.bookmarks); } list.add(new Bookmark(true, getString(R.string.bookmark_current), bs.currentPage, bs.offsetX, bs.offsetY)); } Collections.sort(list); for (final Bookmark b : list) { addBookmarkMenuItem(osm, b); } }
Example #17
Source File: HomeScreenFragment.java From ground-android with Apache License 2.0 | 5 votes |
private void updateSelectedProjectUI(int selectedIndex) { SubMenu subMenu = getProjectsNavItem().getSubMenu(); for (int i = 0; i < projects.size(); i++) { MenuItem menuItem = subMenu.getItem(i); menuItem.setChecked(i == selectedIndex); } }
Example #18
Source File: MusicUtils.java From Rey-MusicPlayer with Apache License 2.0 | 5 votes |
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 #19
Source File: LibraryFragment.java From VinylMusicPlayer with GNU General Public License v3.0 | 5 votes |
private void setUpSortOrderMenu(@NonNull AbsLibraryPagerRecyclerViewCustomGridSizeFragment fragment, @NonNull SubMenu sortOrderMenu) { String currentSortOrder = fragment.getSortOrder(); sortOrderMenu.clear(); if (fragment instanceof AlbumsFragment) { sortOrderMenu.add(0, R.id.action_album_sort_order_asc, 0, R.string.sort_order_a_z) .setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_A_Z)); sortOrderMenu.add(0, R.id.action_album_sort_order_desc, 1, R.string.sort_order_z_a) .setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_Z_A)); sortOrderMenu.add(0, R.id.action_album_sort_order_artist, 2, R.string.sort_order_artist) .setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_ARTIST)); sortOrderMenu.add(0, R.id.action_album_sort_order_year, 3, R.string.sort_order_year) .setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_YEAR)); sortOrderMenu.add(0, R.id.action_album_sort_order_date_added, 4, R.string.sort_order_date_added) .setChecked(currentSortOrder.equals(SortOrder.AlbumSortOrder.ALBUM_DATE_ADDED)); } else if (fragment instanceof ArtistsFragment) { sortOrderMenu.add(0, R.id.action_artist_sort_order_asc, 0, R.string.sort_order_a_z) .setChecked(currentSortOrder.equals(SortOrder.ArtistSortOrder.ARTIST_A_Z)); sortOrderMenu.add(0, R.id.action_artist_sort_order_desc, 1, R.string.sort_order_z_a) .setChecked(currentSortOrder.equals(SortOrder.ArtistSortOrder.ARTIST_Z_A)); } else if (fragment instanceof SongsFragment) { sortOrderMenu.add(0, R.id.action_song_sort_order_asc, 0, R.string.sort_order_a_z) .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_A_Z)); sortOrderMenu.add(0, R.id.action_song_sort_order_desc, 1, R.string.sort_order_z_a) .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_Z_A)); sortOrderMenu.add(0, R.id.action_song_sort_order_artist, 2, R.string.sort_order_artist) .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_ARTIST)); sortOrderMenu.add(0, R.id.action_song_sort_order_album, 3, R.string.sort_order_album) .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_ALBUM)); sortOrderMenu.add(0, R.id.action_song_sort_order_year, 4, R.string.sort_order_year) .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_YEAR)); sortOrderMenu.add(0, R.id.action_song_sort_order_date_added, 5, R.string.sort_order_date_added) .setChecked(currentSortOrder.equals(SortOrder.SongSortOrder.SONG_DATE_ADDED)); } sortOrderMenu.setGroupCheckable(0, true, true); }
Example #20
Source File: DrawerService.java From kolabnotes-android with GNU Lesser General Public License v3.0 | 5 votes |
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); } }
Example #21
Source File: MusicUtils.java From LyricHere with Apache License 2.0 | 5 votes |
/** * 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 #22
Source File: SongsFragment.java From RetroMusicPlayer with GNU General Public License v3.0 | 5 votes |
private void setUpSortOrderMenu(@NonNull SubMenu sortOrder) { sortOrder.removeItem(R.id.action_sort_order_album_desc); sortOrder.removeItem(R.id.action_sort_order_artist_desc); switch (getSavedSortOrder()) { case SongSortOrder.SONG_ALBUM: sortOrder.findItem(R.id.action_sort_order_album).setChecked(true); break; case SongSortOrder.SONG_A_Z: sortOrder.findItem(R.id.action_sort_order_title).setChecked(true); break; case SongSortOrder.SONG_ARTIST: sortOrder.findItem(R.id.action_sort_order_artist).setChecked(true); break; case SongSortOrder.SONG_DATE: sortOrder.findItem(R.id.action_sort_order_date).setChecked(true); break; case SongSortOrder.SONG_DURATION: sortOrder.findItem(R.id.action_sort_order_duration).setChecked(true); break; case SongSortOrder.SONG_YEAR: sortOrder.findItem(R.id.action_sort_order_year).setChecked(true); break; case SongSortOrder.SONG_Z_A: sortOrder.findItem(R.id.action_sort_order_title_desc).setChecked(true); break; } }
Example #23
Source File: MoodleAssignmentsActivity.java From ETSMobile-Android2 with Apache License 2.0 | 5 votes |
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); this.menu = menu; menu.findItem(R.id.menu_item_moodle_previous_assignments).setChecked(moodleViewModel.isDisplayPastAssignments()); SubMenu sortSubMenu = menu.getItem(0).getSubMenu(); sortSubMenu.getItem(moodleViewModel.getAssignmentsSortIndex()).setChecked(true); return true; }
Example #24
Source File: OptionsMenuUtility.java From RedReader with GNU General Public License v3.0 | 5 votes |
private static void addAllPostSorts( final AppCompatActivity activity, final Menu menu, final boolean icon, final boolean includeRising, final boolean includeBest) { final SubMenu sortPosts = menu.addSubMenu(R.string.options_sort_posts); if(icon) { sortPosts.getItem().setIcon(R.drawable.ic_sort_dark); sortPosts.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); } addSort(activity, sortPosts, R.string.sort_posts_hot, PostSort.HOT); addSort(activity, sortPosts, R.string.sort_posts_new, PostSort.NEW); if(includeRising) addSort(activity, sortPosts, R.string.sort_posts_rising, PostSort.RISING); addSort(activity, sortPosts, R.string.sort_posts_controversial, PostSort.CONTROVERSIAL); if(includeBest) addSort(activity, sortPosts, R.string.sort_posts_best, PostSort.BEST); final SubMenu sortPostsTop = sortPosts.addSubMenu(R.string.sort_posts_top); addSort(activity, sortPostsTop, R.string.sort_posts_top_hour, PostSort.TOP_HOUR); addSort(activity, sortPostsTop, R.string.sort_posts_top_today, PostSort.TOP_DAY); addSort(activity, sortPostsTop, R.string.sort_posts_top_week, PostSort.TOP_WEEK); addSort(activity, sortPostsTop, R.string.sort_posts_top_month, PostSort.TOP_MONTH); addSort(activity, sortPostsTop, R.string.sort_posts_top_year, PostSort.TOP_YEAR); addSort(activity, sortPostsTop, R.string.sort_posts_top_all, PostSort.TOP_ALL); }
Example #25
Source File: SocialShareActionProvider.java From android-atleap with Apache License 2.0 | 5 votes |
@Override public void onPrepareSubMenu(SubMenu subMenu) { subMenu.clear(); for (int i = 0; i < SOCIAL_NETWORK_PROVIDERS.size(); i++) { ShareItem shareItem = SOCIAL_NETWORK_PROVIDERS.get(i); subMenu.add(0, i, i, shareItem.name).setOnMenuItemClickListener(this); } }
Example #26
Source File: EffectManager.java From Spectaculum with Apache License 2.0 | 5 votes |
public void addToMenu(Menu menu) { SubMenu submenu = menu.findItem(R.id.action_list_effects).getSubMenu(); int count = 0; for(String effectName : getEffectNames()) { submenu.add(R.id.action_list_effects, count++, Menu.NONE, effectName); } mParameterToggleMenuItem = menu.findItem(R.id.action_toggle_parameters); }
Example #27
Source File: ViewAsActionProvider.java From Contacts with MIT License | 5 votes |
@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 #28
Source File: DrawerService.java From kolabnotes-android with GNU Lesser General Public License v3.0 | 5 votes |
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 #29
Source File: BaseActivity.java From 10000sentences with Apache License 2.0 | 5 votes |
private void setupCollectionsNavigation(NavigationView navigationView) { if (collectionNavigationSet) { return; } collectionNavigationSet = true; SubMenu submenu = navigationView.getMenu().addSubMenu(R.string.downloaded_colections); Map<String, Language> languages = dao.getLanguagesByLanguageID(); for (final SentenceCollection collection : dao.getCollections()) { Language language = languages.get(collection.targetLanguage); if (language == null) { continue; } if (collection.todoCount == 0) { continue; } MenuItem menu = submenu.add(language.name).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { CollectionActivity.start(BaseActivity.this, collection.collectionID); return true; } }); setupMenuIcon(menu, FontAwesomeIcons.fa_language); } }
Example #30
Source File: ShadowSupportMenuInflater.java From open with GNU General Public License v3.0 | 5 votes |
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); } } }