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

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

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

暂无

代码示例

代码示例来源:origin: ankidroid/Anki-Android

@Override
public void onPrepareSubMenu(SubMenu subMenu) {
  subMenu.clear();
  getMenuInflater().inflate(R.menu.reviewer_suspend, subMenu);
  for (int i = 0; i < subMenu.size(); i++) {
    subMenu.getItem(i).setOnMenuItemClickListener(this);
  }
}

代码示例来源:origin: ankidroid/Anki-Android

@Override
public void onPrepareSubMenu(SubMenu subMenu) {
  subMenu.clear();
  getMenuInflater().inflate(R.menu.reviewer_schedule, subMenu);
  for (int i = 0; i < subMenu.size(); i++) {
    subMenu.getItem(i).setOnMenuItemClickListener(this);
  }
}

代码示例来源:origin: ankidroid/Anki-Android

@Override
public void onPrepareSubMenu(SubMenu subMenu) {
  subMenu.clear();
  getMenuInflater().inflate(R.menu.reviewer_bury, subMenu);
  for (int i = 0; i < subMenu.size(); i++) {
    subMenu.getItem(i).setOnMenuItemClickListener(this);
  }
}

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

navView = (NavigationView) findViewById(R.id.navView);
   Menu m = navView.getMenu();
   for (int i=0;i<m.size();i++) {
     MenuItem mi = m.getItem(i);
     //for aapplying a font to subMenu ...
     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);
       }
     }
     //the method we have create in activity
     applyFontToMenuItem(mi);
   }

代码示例来源:origin: Flipboard/bottomsheet

MenuItem subMenuItem = subMenu.getItem(subI);
if (subMenuItem.isVisible()) {
  items.add(SheetMenuItem.of(subMenuItem));

代码示例来源: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: fossasia/pslab-android

private void selectNavMenu() {
  int size_menu = navigationView.getMenu().size();
  for (int i = 0; i < size_menu; i++) {
    final MenuItem item = navigationView.getMenu().getItem(i);
    if (item.hasSubMenu()) {
      unCheckAllMenuItems(item.getSubMenu());
    } else {
      item.setChecked(false);
    }
  }
  switch (navItemIndex) {
    case 0:
    case 1:
    case 2:
      navigationView.getMenu().getItem(navItemIndex).setChecked(true);
      break;
    case 3:
      navigationView.getMenu().getItem(4).getSubMenu().getItem(1).setChecked(true);
      break;
    case 4:
      navigationView.getMenu().getItem(4).getSubMenu().getItem(0).setChecked(true);
      break;
    default:
      navigationView.getMenu().getItem(0).setChecked(true);
      break;
  }
}

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

@Override
public boolean onCreateOptionsMenu(Menu menu) {

  SubMenu sub = menu.addSubMenu("More");
  sub.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
  sub.getItem().setIcon(R.drawable.ic_menu);

  getSupportMenuInflater().inflate(R.menu.activity_main, sub);

  return true;
}

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

@Override
  public MenuItem getItem() {
    if (mItem == null) {
      mItem = new MenuItemWrapper(mNativeSubMenu.getItem());
    }
    return mItem;
  }
}

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

@Override
  public MenuItem getItem() {
    if (mItem == null) {
      mItem = new MenuItemWrapper(mNativeSubMenu.getItem());
    }
    return mItem;
  }
}

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

@Override
public void onPrepareOptionsMenu(Menu menu) {
  super.onPrepareOptionsMenu(menu);
  SubMenu subMenu = menu.getItem(0).getSubMenu();
  for (int i = 0; i <  subMenu.size(); i++) {
    MenuItem menuItem = subMenu.getItem(i);
    CharSequence menuTitle = menuItem.getTitle();
    SpannableString styledMenuTitle = new SpannableString(menuTitle);
    styledMenuTitle.setSpan(new ForegroundColorSpan(Color.BLACK), 0, menuTitle.length(), 0);
    menuItem.setTitle(styledMenuTitle);
  }
}

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

private SubMenu addInternal(android.view.SubMenu nativeSubMenu) {
  SubMenu subMenu = new SubMenuWrapper(nativeSubMenu);
  android.view.MenuItem nativeItem = nativeSubMenu.getItem();
  MenuItem item = subMenu.getItem();
  mNativeMap.put(nativeItem, item);
  return subMenu;
}

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

private SubMenu addInternal(android.view.SubMenu nativeSubMenu) {
  SubMenu subMenu = new SubMenuWrapper(nativeSubMenu);
  android.view.MenuItem nativeItem = nativeSubMenu.getItem();
  MenuItem item = subMenu.getItem();
  mNativeMap.put(nativeItem, item);
  return subMenu;
}

代码示例来源:origin: konradrenner/kolabnotes-android

public void deleteNotebook(String notebookName){
  final SubMenu notebookSubmenu = view.getMenu().findItem(R.id.navigation_notebooks).getSubMenu();
  for(int i=0; i<notebookSubmenu.size(); i++){
    final int currentId = notebookSubmenu.getItem(i).getItemId();
    final String actualTitle = notebookSubmenu.getItem(i).getTitle().toString();
    if(actualTitle.equals(notebookName)){
      notebookSubmenu.removeItem(currentId);
    }
  }
}

代码示例来源: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

public boolean onCreateOptionsMenu(Menu menu) {

SubMenu subMenu = menu.addSubMenu("Add");

subMenu.add("Add Subitem 1").setIcon(R.drawable.ic_action_add1);
subMenu.add("Add Subitem 2").setIcon(R.drawable.ic_action_add2);

MenuItem subMenu1Item = subMenu.getItem();
subMenu1Item.setIcon(R.drawable.ic_action_add);
subMenu1Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

return super.onCreateOptionsMenu(menu);

}

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

@Override
 public boolean onCreateOptionsMenu(Menu menu) {
   super.onCreateOptionsMenu(menu);
   SubMenu subMenu1 = menu.addSubMenu("Action Item");
   subMenu1.add(0, 1, 0, "Sample");
   subMenu1.add(0, 2, 0, "Menu");
   subMenu1.add(0, 3, 0, "Sair");
   MenuItem subMenu1Item = subMenu1.getItem();
   subMenu1Item.setIcon(R.drawable.ic_title_share_default);
   subMenu1Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
   return true;
 }

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

public boolean onCreateOptionsMenu(Menu menu) {
    SubMenu sub = menu.addSubMenu(0,Menu.FIRST,1,"Menu").setIcon(R.drawable.abs__ic_menu_moreoverflow_normal_holo_dark);
     sub.add(0, 2, 0, "Settings");
     sub.add(0, 3, 0, "About");
     sub.add(0, 4, 0, "Exit");
     sub.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
     return true;
 }

相关文章