List of usage examples for android.view SubMenu clear
public void clear();
From source file:br.com.viniciuscr.notification2android.mediaPlayer.MusicUtils.java
/** * 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.// ww w. j a v a2 s . c o m * * @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)); // 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(); } } }
From source file:in.andres.kandroid.ui.MainActivity.java
private void populateProjectsMenu() { if (mProjectList == null) { if (BuildConfig.DEBUG) Log.d("Kandroid", "Tried to populate drawer, but mDashboard was null"); return;/*from w w w .j a v a 2 s .c om*/ } 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); }