android.view.SubMenu.setIcon()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(100)

本文整理了Java中android.view.SubMenu.setIcon()方法的一些代码示例,展示了SubMenu.setIcon()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SubMenu.setIcon()方法的具体详情如下:
包路径:android.view.SubMenu
类名称:SubMenu
方法名:setIcon

暂无

代码示例

代码示例来源:origin: ukanth/afwall

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  // Common options: Copy, Export to SD Card, Refresh
  SubMenu sub = menu.addSubMenu(0, MENU_TOGGLE, 0, "").setIcon(R.drawable.ic_flow);
  sub.add(0, MENU_CLEAR, 0, R.string.clear_log).setIcon(R.drawable.ic_clearlog);
  //sub.add(0, MENU_EXPORT_LOG, 0, R.string.export_to_sd).setIcon(R.drawable.exportr);
  //populateMenu(sub);
  sub.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
  super.onCreateOptionsMenu(menu);
  mainMenu = menu;
  return true;
}

代码示例来源:origin: ukanth/afwall

@Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
  // Common options: Copy, Export to SD Card, Refresh
  SubMenu sub = menu.addSubMenu(0, MENU_TOGGLE, 0, "").setIcon(R.drawable.ic_flow);
  sub.add(0, MENU_CLEAR, 0, R.string.clear_log).setIcon(R.drawable.ic_clearlog);
  sub.add(0, MENU_SWITCH_OLD, 0, R.string.switch_old).setIcon(R.drawable.ic_log);
  //populateMenu(sub);
  sub.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS| MenuItem.SHOW_AS_ACTION_WITH_TEXT);
  super.onCreateOptionsMenu(menu);
  mainMenu = menu;
  return true;
}

代码示例来源:origin: ukanth/afwall

@Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
  // Common options: Copy, Export to SD Card, Refresh
  SubMenu sub = menu.addSubMenu(0, MENU_TOGGLE, 0, "").setIcon(R.drawable.ic_flow);
  sub.add(0, MENU_ZOOM_IN, 0, getString(R.string.label_zoomin)).setIcon(R.drawable.zoomin).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
  sub.add(0, MENU_ZOOM_OUT, 0, getString(R.string.label_zoomout)).setIcon(R.drawable.zoomout).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
  sub.add(0, MENU_COPY, 0, R.string.copy).setIcon(R.drawable.ic_copy);
  sub.add(0, MENU_EXPORT_LOG, 0, R.string.export_to_sd).setIcon(R.drawable.ic_export);
  sub.add(0, MENU_REFRESH, 0, R.string.refresh).setIcon(R.drawable.ic_refresh);
  populateMenu(sub);
  sub.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
  super.onCreateOptionsMenu(menu);
  mainMenu = menu;
  return true;
}

代码示例来源:origin: com.actionbarsherlock/actionbarsherlock

@Override
public SubMenu setIcon(int iconRes) {
  mNativeSubMenu.setIcon(iconRes);
  return this;
}

代码示例来源:origin: com.willowtreeapps/oak-demos

@Override
public SubMenu setIcon(int iconRes) {
  mNativeSubMenu.setIcon(iconRes);
  return this;
}

代码示例来源:origin: com.actionbarsherlock/actionbarsherlock

@Override
public SubMenu setIcon(Drawable icon) {
  mNativeSubMenu.setIcon(icon);
  return this;
}

代码示例来源:origin: com.willowtreeapps/oak-demos

@Override
public SubMenu setIcon(Drawable icon) {
  mNativeSubMenu.setIcon(icon);
  return this;
}

代码示例来源:origin: stackoverflow.com

@Override
 public boolean onCreateOptionsMenu(Menu menu) {
   SubMenu m = menu.addSubMenu(0, 1000, 0, "Go");
   m.setIcon(android.R.drawable.ic_menu_add);
   return super.onCreateOptionsMenu(menu);
 }

代码示例来源:origin: stackoverflow.com

SubMenu sub = menu.addSubMenu("More");
sub.setIcon(R.drawable.abs__ic_menu_moreoverflow_holo_dark);
sub.add(0, MENU_SETTINGS, 0, "Settings");

代码示例来源:origin: stackoverflow.com

private void addCitiestoMenu() {

  cityArrayList = RealmHelper.getStoredCities();
  SubMenu submenu = mDrawerMenu.getItem(0).getSubMenu();
  submenu.setIcon(R.drawable.ic_place_black_24dp);
  submenu.setHeaderTitle("test");

  for (City city : cityArrayList) {
    int cityId = city.getId(); // Get the id (You'll probably need to replace getId() )
    MenuItem item = submenu.add(Menu.NONE, cityId, Menu.NONE, city.getCityName());
    item.setIcon(R.drawable.ic_place_black_24dp);
  }
}

代码示例来源:origin: Phantast/smartnavi

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  subMenu1 = menu.addSubMenu(0, 3, 3, "").setIcon(R.drawable.ic_menu_moreoverflow_normal_holo_dark);
  subMenu1.add(0, 7, 7, getApplicationContext().getResources().getString(R.string.tx_65));
  MenuItem subMenu1Item = subMenu1.getItem();
  subMenu1Item.setIcon(R.drawable.ic_menu_moreoverflow_normal_holo_dark);
  subMenu1Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
  return super.onCreateOptionsMenu(menu);
}

代码示例来源:origin: stackoverflow.com

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  // recreate tree dots sub menu
  final SubMenu subMenu = menu.addSubMenu(null);
  subMenu.setIcon(R.drawable.ic_more_white_24px);
  subMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
  // add items in you new sub menu
  for (MenuData menuData : menuDataList) {
    final MenuItem item = subMenu.add(
      Menu.NONE,
      menuData.id(),
      Menu.NONE,
      menuData.title()
    );
    item.setIcon(menuData.icon());
  }
  return true;
}

代码示例来源:origin: adamantoise/robocrosswords

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  super.onCreateOptionsMenu(menu);
  System.setProperty("http.keepAlive", "false");
  utils.onActionBarWithText(menu.add(MENU_DOWNLOAD).setIcon(android.R.drawable.ic_menu_rotate));
  SubMenu sortMenu = menu.addSubMenu(MENU_SORT)
              .setIcon(android.R.drawable.ic_menu_sort_alphabetically);
  sortMenu.add(MENU_BYDATE_DESCENDING)
      .setIcon(android.R.drawable.ic_menu_day);
  sortMenu.add(MENU_BYDATE_ASCENDING)
      .setIcon(android.R.drawable.ic_menu_day);
  sortMenu.add(MENU_BYSOURCE)
      .setIcon(android.R.drawable.ic_menu_upload);
  sortMenu.add(MENU_BYAUTHOR)
      .setIcon(android.R.drawable.ic_menu_edit);
  utils.onActionBarWithText(sortMenu);
  menu.add(MENU_CLEANUP)
    .setIcon(android.R.drawable.ic_menu_manage);
  menu.add(MENU_ARCHIVES)
    .setIcon(android.R.drawable.ic_menu_view);
  menu.add(MENU_HELP)
    .setIcon(android.R.drawable.ic_menu_help);
  menu.add(MENU_SETTINGS)
    .setIcon(android.R.drawable.ic_menu_preferences);
  return true;
}

代码示例来源:origin: towavephone/MemoryCleaner

@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;
}

代码示例来源:origin: towavephone/MemoryCleaner

@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;
}

代码示例来源:origin: kebernet/shortyz

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  super.onCreateOptionsMenu(menu);
  utils.onActionBarWithoutText(this.gamesItem = menu.add("Sign In")
      .setIcon(this.playIcon));
  if(utils.isNightModeAvailable()) {
    utils.onActionBarWithoutText(menu.add("Night Mode")
        .setIcon(R.drawable.night_toggle));
  }
  SubMenu sortMenu = menu.addSubMenu("Sort")
              .setIcon(android.R.drawable.ic_menu_sort_alphabetically);
  sortMenu.add("By Date (Descending)")
      .setIcon(android.R.drawable.ic_menu_day);
  sortMenu.add("By Date (Ascending)")
      .setIcon(android.R.drawable.ic_menu_day);
  sortMenu.add("By Source")
      .setIcon(android.R.drawable.ic_menu_upload);
  utils.onActionBarWithText(sortMenu);
  menu.add("Cleanup")
    .setIcon(android.R.drawable.ic_menu_manage);
  menu.add(MENU_ARCHIVES)
    .setIcon(android.R.drawable.ic_menu_view);
  menu.add("Help")
    .setIcon(android.R.drawable.ic_menu_help);
  menu.add("Settings")
    .setIcon(android.R.drawable.ic_menu_preferences);
  return true;
}

代码示例来源:origin: IanDarwin/Android-Cookbook-Examples

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  MenuItem mi = menu.add("Main Menu, Option 1");
  mi.setShowAsAction(SHOW_AS_ACTION_IF_ROOM);
  SubMenu sub1 = menu.addSubMenu(GROUP_ID, ITEM_ID , Menu.NONE, R.string.submenu);
  sub1.setHeaderIcon(R.drawable.icon);
  sub1.setIcon(R.drawable.icon);
  sub1.add(GROUP_ID , OPTION_1, 0, "Submenu Option 1");
  sub1.add(GROUP_ID, OPTION_2, 1, "Submenu Option 2");
  return super.onCreateOptionsMenu(menu);
}

代码示例来源:origin: stackoverflow.com

@Override
 public boolean onCreateOptionsMenu(Menu menu)
   {
     // TODO Auto-generated method stub
     SubMenu sub = menu.addSubMenu("Option");
     sub.setIcon(R.drawable.more_btn);
     Spanned others = Html.fromHtml("<b>Other Apps</b>");
     sub.add(0, 1, 0, others).setIcon(R.drawable.other_apps_icon);
     sub.add(0, 2, 0, "About Us").setIcon(R.drawable.about_us_icon);
     sub.add(0, 3, 0, "Share").setIcon(R.drawable.share);
     Spanned audio = Html.fromHtml("<b>Audio Quality</b>");
     sub.add(0, 4, 0, audio).setIcon(R.drawable.top_menu_settings_icon);
     sub.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
     return true;
   }

代码示例来源:origin: adamantoise/robocrosswords

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  super.onCreateOptionsMenu(menu);
  mOptionsMenu = menu;
  int showItemStr = (showErrors ? R.string.menu_hide_errors : R.string.menu_show_errors);
  MenuItem showItem = menu.add(Menu.NONE, MENU_ID_SHOW_ERRORS, Menu.NONE, showItemStr)
    .setIcon(android.R.drawable.ic_menu_view);
  SubMenu reveal = menu.addSubMenu(Menu.NONE, MENU_ID_REVEAL, Menu.NONE, R.string.menu_reveal)
    .setIcon(android.R.drawable.ic_menu_view);
  reveal.add(Menu.NONE, MENU_ID_REVEAL_LETTER, Menu.NONE, R.string.menu_reveal_letter);
  reveal.add(Menu.NONE, MENU_ID_REVEAL_WORD,   Menu.NONE, R.string.menu_reveal_word);
  reveal.add(Menu.NONE, MENU_ID_REVEAL_PUZZLE, Menu.NONE, R.string.menu_reveal_puzzle);
  menu.add(Menu.NONE, MENU_ID_CLUES, Menu.NONE, R.string.menu_clues)
    .setIcon(android.R.drawable.ic_menu_agenda);
  menu.add(Menu.NONE, MENU_ID_INFO, Menu.NONE, R.string.menu_info)
    .setIcon(android.R.drawable.ic_menu_info_details);
  menu.add(Menu.NONE, MENU_ID_HELP, Menu.NONE, R.string.menu_help)
    .setIcon(android.R.drawable.ic_menu_help);
  menu.add(Menu.NONE, MENU_ID_SETTINGS, Menu.NONE, R.string.menu_settings)
    .setIcon(android.R.drawable.ic_menu_preferences);
  maybeAddNotesMenuItem();
  if (WordsWithCrossesApplication.isTabletish(metrics)) {
    utils.onActionBarWithText(showItem);
    utils.onActionBarWithText(reveal);
  }
  return true;
}

代码示例来源:origin: kebernet/shortyz

SubMenu reveal = menu.addSubMenu("Reveal").setIcon(
    android.R.drawable.ic_menu_view);
reveal.add(createSpannableForMenu("Letter")).setTitleCondensed("Letter");

相关文章