private void addWaypoints(final SubMenu subMenu) {
    subMenu.clear();
    for (final Waypoint waypoint : geocache.getWaypoints()) {
      if (waypoint.getCoords() != null) {
        subMenu
            .add(Menu.NONE, waypoint.getId(), Menu.NONE, waypoint.getName())
            .setOnMenuItemClickListener(
                new OnMenuItemClickListener() {

                  @Override
                  public boolean onMenuItemClick(final MenuItem item) {
                    callback.onWaypointSelected(waypoint);
                    return true;
                  }
                });
      }
    }
    subMenu
        .add(Menu.NONE, Menu.NONE, Menu.NONE, getContext().getString(R.string.cache))
        .setOnMenuItemClickListener(
            new OnMenuItemClickListener() {

              @Override
              public boolean onMenuItemClick(final MenuItem item) {
                callback.onGeocacheSelected(geocache);
                return true;
              }
            });
  }
示例#2
0
  /** On options menu creation. */
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {

    // ===

    SubMenu sortMenu = menu.addSubMenu(group2Id, MENU_ITEM_SORT, sortBtnId, R.string.logsmenu_sort);
    sortMenu.add(MENU_ITEM_SORT, MENU_ITEM_SORT_ALL, 0, R.string.logsmenu_sort_all);
    sortMenu.add(MENU_ITEM_SORT, MENU_ITEM_SORT_BY_XODIL, 1, R.string.logsmenu_sort_xodil);
    sortMenu.add(
        MENU_ITEM_SORT, MENU_ITEM_SORT_BY_PODTVERDIL, 2, R.string.logsmenu_sort_podtverdil);
    sortMenu.setIcon(android.R.drawable.ic_menu_sort_alphabetically);

    // // ===
    // MenuItem item_2 = menu.add(group2Id, MENU_ITEM_LOGSTEXT,
    // logstextBtnId, R.string.logsmenu_sort_all);
    // item_2.setIcon(android.R.drawable.ic_menu_edit);

    // // ===
    // MenuItem item_2 = menu.add(group2Id, MENU_ITEM_SORT_ALL,
    // sortAllBtnId, R.string.logsmenu_sort_all);
    // item_2.setIcon(android.R.drawable.ic_menu_edit);
    //
    // // ===
    // MenuItem item_3 = menu.add(group2Id, MENU_ITEM_SORT_BY_PODTVERDIL,
    // sortPodtverdilBtnId, R.string.logsmenu_sort_podtverdil);
    // item_3.setIcon(android.R.drawable.ic_menu_sort_by_size);

    return super.onCreateOptionsMenu(menu);
  }
 public void onPrepareSubMenu(SubMenu subMenu) {
   int i;
   subMenu.clear();
   ActivityChooserModel dataModel =
       ActivityChooserModel.get(this.mContext, this.mShareHistoryFileName);
   PackageManager packageManager = this.mContext.getPackageManager();
   int expandedActivityCount = dataModel.getActivityCount();
   int collapsedActivityCount = Math.min(expandedActivityCount, this.mMaxShownActivityCount);
   for (i = 0; i < collapsedActivityCount; i++) {
     ResolveInfo activity = dataModel.getActivity(i);
     subMenu
         .add(0, i, i, activity.loadLabel(packageManager))
         .setIcon(activity.loadIcon(packageManager))
         .setOnMenuItemClickListener(this.mOnMenuItemClickListener);
   }
   if (collapsedActivityCount < expandedActivityCount) {
     SubMenu expandedSubMenu =
         subMenu.addSubMenu(
             0,
             collapsedActivityCount,
             collapsedActivityCount,
             this.mContext.getString(C0103R.string.abc_activity_chooser_view_see_all));
     for (i = 0; i < expandedActivityCount; i++) {
       activity = dataModel.getActivity(i);
       expandedSubMenu
           .add(0, i, i, activity.loadLabel(packageManager))
           .setIcon(activity.loadIcon(packageManager))
           .setOnMenuItemClickListener(this.mOnMenuItemClickListener);
     }
   }
 }
 @Override
 public void createExtraMenuOptions(Menu menu) {
   SubMenu favsmenu =
       menu.addSubMenu(0, 0, 15, "Favs & More").setIcon(android.R.drawable.ic_menu_add);
   favsmenu.add(0, AppConstants.MENU_ADDFAV, 0, "Add Fav").setIcon(android.R.drawable.ic_menu_add);
   favsmenu
       .add(0, AppConstants.MENU_REMFAV, 0, "Remove Fav")
       .setIcon(android.R.drawable.ic_menu_close_clear_cancel);
   favsmenu.add(0, AppConstants.MENU_RATE, 0, "Rate").setIcon(android.R.drawable.btn_star_big_off);
   favsmenu.add(0, AppConstants.MENU_OPEN_BROWSER, 0, "Open in Browser");
   SubMenu usermenu = menu.addSubMenu(0, 0, 20, "Author").setIcon(android.R.drawable.ic_menu_more);
   usermenu.add(0, AppConstants.MENU_WATCH, 0, "Watch").setIcon(android.R.drawable.ic_menu_search);
   usermenu
       .add(0, AppConstants.MENU_UNWATCH, 0, "Unwatch")
       .setIcon(android.R.drawable.ic_menu_delete);
   usermenu
       .add(0, AppConstants.MENU_USERSSTORIES, 0, "Author's Stories")
       .setIcon(android.R.drawable.ic_menu_slideshow);
   usermenu
       .add(0, AppConstants.MENU_USERSART, 0, "Author's Art")
       .setIcon(android.R.drawable.ic_menu_slideshow);
   usermenu
       .add(0, AppConstants.MENU_USERSMUSIK, 0, "Author's Music")
       .setIcon(android.R.drawable.ic_menu_slideshow);
 }
示例#5
0
 /**
  * Sets up the options menu when the menu button is push, dynamic population of the station select
  * menu
  */
 public boolean onPrepareOptionsMenu(Menu menu) {
   menu.clear();
   boolean result = super.onCreateOptionsMenu(menu);
   SubMenu subMenu = menu.addSubMenu(BASE_OPTION_MENU, FM_BAND, Menu.NONE, R.string.band_select);
   subMenu.setIcon(android.R.drawable.ic_menu_mapmode);
   // Populate the band selection menu
   subMenu.add(BAND_SELECTION_MENU, BAND_US, Menu.NONE, R.string.band_us);
   subMenu.add(BAND_SELECTION_MENU, BAND_EU, Menu.NONE, R.string.band_eu);
   subMenu.add(BAND_SELECTION_MENU, BAND_CHINA, Menu.NONE, R.string.band_ch);
   subMenu.add(BAND_SELECTION_MENU, BAND_JAPAN, Menu.NONE, R.string.band_ja);
   subMenu.setGroupCheckable(BAND_SELECTION_MENU, true, true);
   subMenu.getItem(mSelectedBand).setChecked(true);
   return result;
 }
  @Override
  public void onPrepareSubMenu(final SubMenu subMenu) {
    subMenu.clear();
    if (geocache == null) {
      return;
    }
    for (final NavigationAppsEnum app : NavigationAppFactory.getActiveNavigationApps()) {
      if (!(app.app instanceof CacheNavigationApp)) {
        continue;
      }
      final CacheNavigationApp cacheApp = (CacheNavigationApp) app.app;
      if (app.app.isEnabled(geocache)) {
        subMenu
            .add(Menu.NONE, app.id, Menu.NONE, app.app.getName())
            .setOnMenuItemClickListener(
                new OnMenuItemClickListener() {

                  @Override
                  public boolean onMenuItemClick(final MenuItem item) {
                    cacheApp.navigate(activity, geocache);
                    return true;
                  }
                });
      }
    }
  }
示例#7
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    if (settings.useCompass == 1) {
      menu.add(0, 1, 0, res.getString(R.string.use_gps))
          .setIcon(android.R.drawable.ic_menu_compass);
    } else {
      menu.add(0, 1, 0, res.getString(R.string.use_compass))
          .setIcon(android.R.drawable.ic_menu_compass);
    }
    menu.add(0, 0, 0, res.getString(R.string.caches_on_map))
        .setIcon(android.R.drawable.ic_menu_mapmode);
    menu.add(0, 2, 0, res.getString(R.string.destination_set))
        .setIcon(android.R.drawable.ic_menu_edit);
    if (coordinates.size() > 1) {
      SubMenu subMenu =
          menu.addSubMenu(0, 3, 0, res.getString(R.string.destination_select))
              .setIcon(android.R.drawable.ic_menu_myplaces);

      int cnt = 4;
      for (cgCoord coordinate : coordinates) {
        subMenu.add(0, cnt, 0, coordinate.name + " (" + coordinate.type + ")");
        cnt++;
      }

      return true;
    } else {
      menu.add(0, 3, 0, res.getString(R.string.destination_select))
          .setIcon(android.R.drawable.ic_menu_myplaces)
          .setEnabled(false);

      return true;
    }
  }
示例#8
0
  @Override
  public boolean onCreateOptionsMenu(final Menu menu) {
    getMenuInflater().inflate(R.menu.abstract_logging_activity, menu);

    final SubMenu menuLog = menu.findItem(R.id.menu_templates).getSubMenu();
    for (final LogTemplate template : LogTemplateProvider.getTemplatesWithSignature()) {
      menuLog.add(0, template.getItemId(), 0, template.getResourceId());
    }

    final SubMenu menuSmilies = menu.findItem(R.id.menu_smilies).getSubMenu();
    for (final Smiley smiley : GCSmiliesProvider.getSmilies()) {
      menuSmilies.add(0, smiley.getItemId(), 0, smiley.text);
    }

    return true;
  }
示例#9
0
 @Override
 public boolean onPrepareOptionsMenu(Menu menu) {
   super.onPrepareOptionsMenu(menu);
   hackForSubmenus = menu;
   if (progress != null && (actionBarCompat == null || actionBarCompat.hasMenuButton()))
     return false; // not safe/useful until game is loaded
   MenuItem item;
   item = menu.findItem(R.id.solve);
   item.setEnabled(solveEnabled);
   if (actionBarCompat != null) item.setVisible(solveEnabled);
   MenuItem undoItem = menu.findItem(R.id.undo), redoItem = menu.findItem(R.id.redo);
   undoItem.setEnabled(undoEnabled);
   redoItem.setEnabled(redoEnabled);
   undoItem.setIcon(
       undoEnabled ? R.drawable.sym_keyboard_undo : R.drawable.sym_keyboard_undo_disabled);
   redoItem.setIcon(
       redoEnabled ? R.drawable.sym_keyboard_redo : R.drawable.sym_keyboard_redo_disabled);
   item = menu.findItem(R.id.type);
   item.setEnabled(!gameTypes.isEmpty() || customVisible);
   if (actionBarCompat != null) item.setVisible(item.isEnabled());
   typeMenu = item.getSubMenu();
   for (Integer i : gameTypes.keySet()) {
     if (menu.findItem(i) == null) typeMenu.add(R.id.typeGroup, i, Menu.NONE, gameTypes.get(i));
   }
   MenuItem customItem = menu.findItem(R.id.custom);
   customItem.setVisible(customVisible);
   typeMenu.setGroupCheckable(R.id.typeGroup, true, true);
   if (currentType < 0) customItem.setChecked(true);
   else if (currentType < gameTypes.size())
     menu.findItem((Integer) gameTypes.keySet().toArray()[currentType]).setChecked(true);
   menu.findItem(R.id.thisgame)
       .setTitle(
           MessageFormat.format(getString(R.string.help_on_game), new Object[] {this.getTitle()}));
   return true;
 }
示例#10
0
文件: Main.java 项目: lucEvent/NewsUp
  private void updateDrawer(boolean updateFavorites) {
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    assert navigationView != null : "Navigation view is null";

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
      navigationView.setItemIconTintList(null);

    MenuItem stats = navigationView.getMenu().findItem(R.id.nav_stats);
    if (ProSettings.checkEnabled(ProSettings.STATISTICS_KEY)) stats.setVisible(true);
    else stats.setVisible(false);

    MenuItem notes = navigationView.getMenu().findItem(R.id.nav_notes);
    if (ProSettings.checkEnabled(ProSettings.NOTES_KEY)) notes.setVisible(true);
    else notes.setVisible(false);

    if (updateFavorites) {
      SubMenu fab_menu = navigationView.getMenu().findItem(R.id.nav_header_favorites).getSubMenu();
      fab_menu.clear();

      Sites favorites = dataManager.getFavoriteSites();
      for (Site site : favorites) {
        MenuItem mi = fab_menu.add(2, site.code, Menu.NONE, site.name);
        configureMenuItem(mi, site);
      }
    }
    navigationView.invalidate();
  }
示例#11
0
  @Override
  public boolean onCreateOptionsMenu(
      final Menu pMenu, final int pMenuIdOffset, final MapView pMapView) {
    final SubMenu mapMenu =
        pMenu
            .addSubMenu(0, MENU_MAP_MODE + pMenuIdOffset, 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);
    }
    return true;
  }
示例#12
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    SubMenu subMenu =
        menu.addSubMenu(0, 0, 0, res.getString(R.string.log_add))
            .setIcon(android.R.drawable.ic_menu_add);

    subMenu.add(0, 0x6, 0, res.getString(R.string.log_date_time));
    subMenu.add(0, 0x4, 0, res.getString(R.string.log_date));
    subMenu.add(0, 0x2, 0, res.getString(R.string.log_time));
    subMenu.add(0, 0x1, 0, res.getString(R.string.init_signature));
    subMenu.add(
        0,
        0x7,
        0,
        res.getString(R.string.log_date_time) + " & " + res.getString(R.string.init_signature));

    return true;
  }
  /** {@inheritDoc} */
  @DSSafe(DSCat.SAFE_LIST)
  @DSGenerator(
      tool_name = "Doppelganger",
      tool_version = "2.0",
      generated_on = "2014-09-18 21:46:52.211 -0400",
      hash_original_method = "5458A50E7CC261A43D8FD66D69514BF7",
      hash_generated_method = "9C9DCF571226F099D8D0DA86C844CB03")
  @Override
  public void onPrepareSubMenu(SubMenu subMenu) {
    // Clear since the order of items may change.
    subMenu.clear();

    ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
    PackageManager packageManager = mContext.getPackageManager();

    final int expandedActivityCount = dataModel.getActivityCount();
    final int collapsedActivityCount = Math.min(expandedActivityCount, mMaxShownActivityCount);

    // Populate the sub-menu with a sub set of the activities.
    for (int i = 0; i < collapsedActivityCount; i++) {
      ResolveInfo activity = dataModel.getActivity(i);
      subMenu
          .add(0, i, i, activity.loadLabel(packageManager))
          .setIcon(activity.loadIcon(packageManager))
          .setOnMenuItemClickListener(mOnMenuItemClickListener);
    }

    if (collapsedActivityCount < expandedActivityCount) {
      // Add a sub-menu for showing all activities as a list item.
      SubMenu expandedSubMenu =
          subMenu.addSubMenu(
              Menu.NONE,
              collapsedActivityCount,
              collapsedActivityCount,
              mContext.getString(R.string.abc_activity_chooser_view_see_all));
      for (int i = 0; i < expandedActivityCount; i++) {
        ResolveInfo activity = dataModel.getActivity(i);
        expandedSubMenu
            .add(0, i, i, activity.loadLabel(packageManager))
            .setIcon(activity.loadIcon(packageManager))
            .setOnMenuItemClickListener(mOnMenuItemClickListener);
      }
    }
  }
示例#14
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    List<String> effects = mOpenCvCameraView.getEffectList();

    if (effects == null) {
      Log.e(TAG, "Color effects are not supported by device!");
      return true;
    }

    mColorEffectsMenu = menu.addSubMenu("Color Effect");
    mEffectMenuItems = new MenuItem[effects.size()];

    int idx = 0;
    ListIterator<String> effectItr = effects.listIterator();
    while (effectItr.hasNext()) {
      String element = effectItr.next();
      mEffectMenuItems[idx] = mColorEffectsMenu.add(1, idx, Menu.NONE, element);
      idx++;
    }

    mResolutionMenu = menu.addSubMenu("Resolution");
    mResolutionList = mOpenCvCameraView.getResolutionList();
    mResolutionMenuItems = new MenuItem[mResolutionList.size()];

    ListIterator<Size> resolutionItr = mResolutionList.listIterator();
    idx = 0;
    while (resolutionItr.hasNext()) {
      Size element = resolutionItr.next();
      mResolutionMenuItems[idx] =
          mResolutionMenu.add(
              2,
              idx,
              Menu.NONE,
              Integer.valueOf(element.width).toString()
                  + "x"
                  + Integer.valueOf(element.height).toString());
      idx++;
    }

    return true;
  }
  public static void addMapviewMenuItems(final Menu menu) {
    final SubMenu parentMenu = menu.findItem(R.id.menu_select_mapview).getSubMenu();

    final int currentSource = Settings.getMapSource().getNumericalId();
    for (int i = 0; i < mapSources.size(); i++) {
      final MapSource mapSource = mapSources.get(i);
      final int id = mapSource.getNumericalId();
      parentMenu
          .add(R.id.menu_group_map_sources, id, i, mapSource.getName())
          .setCheckable(true)
          .setChecked(id == currentSource);
    }
    parentMenu.setGroupCheckable(R.id.menu_group_map_sources, true, true);
  }
 /**
  * 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));
         //                    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();
     }
   }
 }
 @Override
 public void onCreateOptionsMenu(Menu menu) {
   if (mActor != null || mGenre != null) {
     menu.add(0, MENU_PLAY_ALL, 0, "Play all").setIcon(R.drawable.menu_album);
   }
   SubMenu sortMenu = menu.addSubMenu(0, MENU_SORT, 0, "Sort").setIcon(R.drawable.menu_sort);
   sortMenu.add(2, MENU_SORT_BY_TITLE_ASC, 0, "by Title ascending");
   sortMenu.add(2, MENU_SORT_BY_TITLE_DESC, 0, "by Title descending");
   sortMenu.add(2, MENU_SORT_BY_YEAR_ASC, 0, "by Year ascending");
   sortMenu.add(2, MENU_SORT_BY_YEAR_DESC, 0, "by Year descending");
   sortMenu.add(2, MENU_SORT_BY_RATING_ASC, 0, "by Rating ascending");
   sortMenu.add(2, MENU_SORT_BY_RATING_DESC, 0, "by Rating descending");
   sortMenu.add(2, MENU_SORT_BY_DATE_ADDED_ASC, 0, "by Date Added ascending");
   sortMenu.add(2, MENU_SORT_BY_DATE_ADDED_DESC, 0, "by Date Added descending");
   //		menu.add(0, MENU_SWITCH_VIEW, 0, "Switch view").setIcon(R.drawable.menu_view);
   createShowHideWatchedToggle(menu);
 }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    menu.add(0, MENU_ID_COMPASS, 0, res.getString(R.string.cache_menu_compass))
        .setIcon(android.R.drawable.ic_menu_compass); // compass

    SubMenu subMenu =
        menu.addSubMenu(1, MENU_ID_NAVIGATION, 0, res.getString(R.string.cache_menu_navigate))
            .setIcon(android.R.drawable.ic_menu_more);
    subMenu.add(0, MENU_ID_RADAR, 0, res.getString(R.string.cache_menu_radar)); // radar
    subMenu.add(0, MENU_ID_MAP, 0, res.getString(R.string.cache_menu_map)); // c:geo map
    if (base.isLocus(activity)) {
      subMenu.add(0, MENU_ID_LOCUS, 0, res.getString(R.string.cache_menu_locus)); // ext.: locus
    }
    if (base.isRmaps(activity)) {
      subMenu.add(0, MENU_ID_RMAPS, 0, res.getString(R.string.cache_menu_rmaps)); // ext.: rmaps
    }
    subMenu.add(0, MENU_ID_EXTERN, 0, res.getString(R.string.cache_menu_map_ext)); // ext.: other
    subMenu.add(0, MENU_ID_TURNBYTURN, 0, res.getString(R.string.cache_menu_tbt)); // turn-by-turn

    menu.add(0, MENU_ID_CACHES_AROUND, 0, res.getString(R.string.cache_menu_around))
        .setIcon(android.R.drawable.ic_menu_rotate); // caches around

    return true;
  }
示例#19
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   MenuItem item;
   item = menu.add(Menu.NONE, MENU_UNDO, Menu.NONE, R.string.undo);
   item.setIcon(R.drawable.ic_menu_revert);
   item = menu.add(Menu.NONE, MENU_REDO, Menu.NONE, R.string.redo);
   item.setIcon(R.drawable.ic_menu_redo);
   item = menu.add(Menu.NONE, MENU_ADD_FACT, Menu.NONE, R.string.add);
   item.setIcon(R.drawable.ic_menu_add);
   item =
       menu.add(
           Menu.NONE, MENU_CHANGE_ORDER, Menu.NONE, R.string.card_browser_change_display_order);
   item.setIcon(R.drawable.ic_menu_sort_by_size);
   item = menu.add(Menu.NONE, MENU_SHOW_MARKED, Menu.NONE, R.string.card_browser_show_marked);
   item.setIcon(R.drawable.ic_menu_star_on);
   SubMenu selectSubMenu =
       menu.addSubMenu(Menu.NONE, MENU_SELECT, Menu.NONE, R.string.card_browser_search);
   selectSubMenu.setIcon(R.drawable.ic_menu_search);
   selectSubMenu.add(
       Menu.NONE, MENU_SELECT_SUSPENDED, Menu.NONE, R.string.card_browser_search_suspended);
   selectSubMenu.add(Menu.NONE, MENU_SELECT_TAG, Menu.NONE, R.string.card_browser_search_by_tag);
   item.setIcon(R.drawable.ic_menu_close_clear_cancel);
   return true;
 }
    public void onPrepareSubMenu(SubMenu submenu)
    {
        submenu.clear();
        cg cg1 = cg.a(c, d);
        android.content.pm.PackageManager packagemanager = c.getPackageManager();
        int k = cg1.a();
        int l = Math.min(k, a);
        for (int i = 0; i < l; i++)
        {
            ResolveInfo resolveinfo = cg1.a(i);
            submenu.add(0, i, i, resolveinfo.loadLabel(packagemanager)).setIcon(resolveinfo.loadIcon(packagemanager)).setOnMenuItemClickListener(b);
        }

        if (l < k)
        {
            submenu = submenu.addSubMenu(0, l, l, c.getString(z.abc_activity_chooser_view_see_all));
            for (int j = 0; j < k; j++)
            {
                ResolveInfo resolveinfo1 = cg1.a(j);
                submenu.add(0, j, j, resolveinfo1.loadLabel(packagemanager)).setIcon(resolveinfo1.loadIcon(packagemanager)).setOnMenuItemClickListener(b);
            }

        }
    }
示例#21
0
 private void buildAddMenu(SubMenu subMenu) {
   subMenu
       .add(getString(R.string.s_Folder))
       .setOnMenuItemClickListener(
           new OnMenuItemClickListener() {
             @Override
             public boolean onMenuItemClick(MenuItem item) {
               menuItemClick(MenuId.FOLDER_ADD.getId());
               return false;
             }
           });
   for (final Entry<Integer, Interpreter> entry : mAddMenuIds.entrySet()) {
     subMenu
         .add(entry.getValue().getNiceName())
         .setOnMenuItemClickListener(
             new OnMenuItemClickListener() {
               @Override
               public boolean onMenuItemClick(MenuItem item) {
                 menuItemClick(entry.getKey());
                 return false;
               }
             });
   }
 }
 protected void populateMenu(Menu menu) {
   LinkedHashMap<String, String> types = getDocTypesForCreation();
   if (types.size() > 0) {
     if (types.size() == 1) {
       menu.add(Menu.NONE, MNU_NEW_LISTITEM, 0, "New Item");
     } else {
       SubMenu subMenu = menu.addSubMenu(Menu.NONE, MNU_NEW_LISTITEM, 0, "New item");
       int idx = 1;
       for (String key : types.keySet()) {
         subMenu.add(Menu.NONE, MNU_NEW_LISTITEM + idx, idx, types.get(key));
         idx++;
       }
     }
   }
   // menu.add(Menu.NONE, MNU_VIEW_LIST_EXTERNAL, 1, "External View");
   menu.add(Menu.NONE, MNU_REFRESH, 2, "Refresh");
 }
  @Override
  public void onPrepareSubMenu(SubMenu subMenu) {
    // Clear since the order of items may change.
    subMenu.clear();

    ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mHistoryFileName);
    PackageManager packageManager = mContext.getPackageManager();

    // Populate the sub-menu with a sub set of the activities.
    final int count = dataModel.getActivityCount();
    for (int i = 0; i < count; i++) {
      ResolveInfo activity = dataModel.getActivity(i);
      subMenu
          .add(0, i, i, activity.loadLabel(packageManager))
          .setIcon(activity.loadIcon(packageManager))
          .setOnMenuItemClickListener(mCallbacks);
    }
  }
  @Override
  public boolean onCreateOptionsMenu(final Menu pMenu) {
    pMenu.add(0, MENU_ZOOMIN_ID, Menu.NONE, "ZoomIn");
    pMenu.add(0, MENU_ZOOMOUT_ID, Menu.NONE, "ZoomOut");

    final SubMenu subMenu =
        pMenu.addSubMenu(0, MENU_TILE_SOURCE_ID, Menu.NONE, "Choose Tile Source");
    {
      for (final ITileSource tileSource : TileSourceFactory.getTileSources()) {
        subMenu.add(
            0, 1000 + tileSource.ordinal(), Menu.NONE, tileSource.localizedName(mResourceProxy));
      }
    }

    pMenu.add(0, MENU_ANIMATION_ID, Menu.NONE, "Run Animation");
    pMenu.add(0, MENU_MINIMAP_ID, Menu.NONE, "Toggle Minimap");

    return true;
  }
  /**
   * Prepare the Screen's standard options menu to be displayed. This is called right before the
   * menu is shown, every time it is shown. You can use this method to efficiently enable/disable
   * items or otherwise dynamically modify the contents. See {@link
   * android.app.Activity#onPrepareOptionsMenu(android.view.Menu) Activity.onPrepareOptionsMenu} for
   * more information.
   *
   * @param menu The options menu as last shown or first initialized by onCreateOptionsMenu().
   * @see #setHasOptionsMenu
   * @see #onCreateOptionsMenu
   */
  @Override
  public void onPrepareOptionsMenu(Menu menu) {

    menu.clear();

    MenuItem mItemSearch =
        menu.add(Menu.NONE, MENU_ITEM_SEARCH, Menu.NONE, getString(R.string.search));
    mItemSearch.setIcon(
        new IconDrawable(getActivity(), Iconify.IconValue.fa_search)
            .colorRes(R.color.black)
            .actionBarSize());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      mItemSearch.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    menu.addSubMenu(
        Menu.NONE, MENU_ITEM_DATA_TABLES, Menu.NONE, Constants.DATA_TABLE_SAVINGS_ACCOUNTS_NAME);
    menu.add(
        Menu.NONE, MENU_ITEM_DOCUMENTS, Menu.NONE, getResources().getString(R.string.documents));

    // This is the ID of Each data table which will be used in onOptionsItemSelected Method
    int SUBMENU_ITEM_ID = 0;

    // Create a Sub Menu that holds a link to all data tables
    SubMenu dataTableSubMenu = menu.getItem(1).getSubMenu();
    if (dataTableSubMenu != null
        && savingsAccountDataTables != null
        && savingsAccountDataTables.size() > 0) {
      Iterator<DataTable> dataTableIterator = savingsAccountDataTables.iterator();
      while (dataTableIterator.hasNext()) {
        dataTableSubMenu.add(
            Menu.NONE,
            SUBMENU_ITEM_ID,
            Menu.NONE,
            dataTableIterator.next().getRegisteredTableName());
        SUBMENU_ITEM_ID++;
      }
    }

    super.onPrepareOptionsMenu(menu);
  }
 /**
  * @param menu
  * @param activity
  * @param res
  * @return the added menu item (also for a sub menu, then the menu item in the parent menu is
  *     returned)
  */
 public static MenuItem addMenuItems(Menu menu, Activity activity, Resources res) {
   List<CacheListApp> activeApps = new ArrayList<CacheListApp>();
   for (CacheListApp app : getMultiPointNavigationApps()) {
     if (app.isInstalled(activity)) {
       activeApps.add(app);
     }
   }
   // use a new sub menu, if more than one app is available
   if (activeApps.size() > 1) {
     SubMenu subMenu =
         menu.addSubMenu(0, 101, 0, res.getString(R.string.caches_on_map))
             .setIcon(android.R.drawable.ic_menu_mapmode);
     for (CacheListApp app : activeApps) {
       subMenu.add(0, app.getId(), 0, app.getName());
     }
     return subMenu.getItem();
   } else if (activeApps.size() == 1) {
     return menu.add(0, activeApps.get(0).getId(), 0, activeApps.get(0).getName())
         .setIcon(android.R.drawable.ic_menu_mapmode);
   }
   return null;
 }
示例#27
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {

    // Alternativa 1

    // getMenuInflater().inflate(R.menu.activity_main, menu);

    // Alternativa 2

    menu.add(Menu.NONE, MNU_OPC1, Menu.NONE, "Opcion1")
        .setIcon(android.R.drawable.ic_menu_preferences);

    menu.add(Menu.NONE, MNU_OPC2, Menu.NONE, "Opcion2").setIcon(android.R.drawable.ic_menu_compass);

    SubMenu smnu =
        menu.addSubMenu(Menu.NONE, MNU_OPC1, Menu.NONE, "Opcion3")
            .setIcon(android.R.drawable.ic_menu_agenda);

    smnu.add(Menu.NONE, SMNU_OPC1, Menu.NONE, "Opcion 3.1");
    smnu.add(Menu.NONE, SMNU_OPC2, Menu.NONE, "Opcion 3.2");

    return true;
  }
  @Override
  public void onCreateOptionsMenu(Menu menu) {
    if (mArtist != null || mGenre != null) {
      menu.add(0, MENU_PLAY_ALL, 0, "Play all").setIcon(R.drawable.menu_album);
    }
    SubMenu sortMenu = menu.addSubMenu(0, MENU_SORT, 0, "Sort").setIcon(R.drawable.menu_sort);
    sortMenu.add(2, MENU_SORT_BY_ALBUM_ASC, 0, "by Album ascending");
    sortMenu.add(2, MENU_SORT_BY_ALBUM_DESC, 0, "by Album descending");

    if (mArtist != null) {
      sortMenu.add(2, MENU_SORT_BY_YEAR_ASC, 0, "by Year ascending");
      sortMenu.add(2, MENU_SORT_BY_YEAR_DESC, 0, "by Year descending");
    } else {
      sortMenu.add(2, MENU_SORT_BY_ARTIST_ASC, 0, "by Artist ascending");
      sortMenu.add(2, MENU_SORT_BY_ARTIST_DESC, 0, "by Artist descending");
    }
    //		menu.add(0, MENU_SWITCH_VIEW, 0, "Switch view").setIcon(R.drawable.menu_view);
  }
  @Override
  public boolean onPrepareOptionsMenu(Menu menu) {
    if (isFinishing()) {
      return false;
    }
    menu.clear();

    SlideModel slide = mSlideshowModel.get(mPosition);

    if (slide == null) {
      return false;
    }

    // Preview slideshow.
    menu.add(0, MENU_PREVIEW_SLIDESHOW, 0, R.string.preview_slideshow)
        .setIcon(com.android.internal.R.drawable.ic_menu_play_clip);

    // Text
    if (slide.hasText() && !TextUtils.isEmpty(slide.getText().getText())) {
      // "Change text" if text is set.
      menu.add(0, MENU_REMOVE_TEXT, 0, R.string.remove_text)
          .setIcon(R.drawable.ic_menu_remove_text);
    }

    // Picture
    if (slide.hasImage()) {
      menu.add(0, MENU_DEL_PICTURE, 0, R.string.remove_picture)
          .setIcon(R.drawable.ic_menu_remove_picture);
    } else if (!slide.hasVideo()) {
      menu.add(0, MENU_ADD_PICTURE, 0, R.string.add_picture).setIcon(R.drawable.ic_menu_picture);
      menu.add(0, MENU_TAKE_PICTURE, 0, R.string.attach_take_photo)
          .setIcon(R.drawable.ic_menu_picture);
    }

    // Music
    if (slide.hasAudio()) {
      menu.add(0, MENU_DEL_AUDIO, 0, R.string.remove_music)
          .setIcon(R.drawable.ic_menu_remove_sound);
    } else if (!slide.hasVideo()) {
      if (MmsConfig.getAllowAttachAudio()) {
        SubMenu subMenu =
            menu.addSubMenu(0, MENU_SUB_AUDIO, 0, R.string.add_music)
                .setIcon(R.drawable.ic_menu_add_sound);
        subMenu.add(0, MENU_ADD_AUDIO, 0, R.string.attach_sound);
        subMenu.add(0, MENU_RECORD_SOUND, 0, R.string.attach_record_sound);
      } else {
        menu.add(0, MENU_RECORD_SOUND, 0, R.string.attach_record_sound)
            .setIcon(R.drawable.ic_menu_add_sound);
      }
    }

    // Video
    if (slide.hasVideo()) {
      menu.add(0, MENU_DEL_VIDEO, 0, R.string.remove_video)
          .setIcon(R.drawable.ic_menu_remove_video);
    } else if (!slide.hasAudio() && !slide.hasImage()) {
      menu.add(0, MENU_ADD_VIDEO, 0, R.string.add_video).setIcon(R.drawable.ic_menu_movie);
      menu.add(0, MENU_TAKE_VIDEO, 0, R.string.attach_record_video)
          .setIcon(R.drawable.ic_menu_movie);
    }

    // Add slide
    menu.add(0, MENU_ADD_SLIDE, 0, R.string.add_slide).setIcon(R.drawable.ic_menu_add_slide);

    // Slide duration
    String duration = getResources().getString(R.string.duration_sec);
    menu.add(
            0, MENU_DURATION, 0, duration.replace("%s", String.valueOf(slide.getDuration() / 1000)))
        .setIcon(R.drawable.ic_menu_duration);

    // Slide layout
    int resId;
    if (mSlideshowModel.getLayout().getLayoutType() == LayoutModel.LAYOUT_TOP_TEXT) {
      resId = R.string.layout_top;
    } else {
      resId = R.string.layout_bottom;
    }
    // FIXME: set correct icon when layout icon is available.
    menu.add(0, MENU_LAYOUT, 0, resId).setIcon(R.drawable.ic_menu_picture);
    return true;
  }
 public static void addItems2Menu(Menu menu, int idx, String nume, ViewPager vp) {
   final SubMenu smenu = menu.addSubMenu(0, idx, 0, nume);
   for (int i = 0; i < vp.getAdapter().getCount(); i++) {
     if (i != vp.getCurrentItem()) smenu.add(0, idx + i + 1, 0, vp.getAdapter().getPageTitle(i));
   }
 }