本文整理了Java中android.view.SubMenu.add()
方法的一些代码示例,展示了SubMenu.add()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SubMenu.add()
方法的具体详情如下:
包路径:android.view.SubMenu
类名称:SubMenu
方法名:add
暂无
代码示例来源:origin: stackoverflow.com
SubMenu submenu = menu.addSubMenu(0, Menu.NONE, 1, "New Form").setIcon(R.drawable.ic_new_form);
submenu.add("Form 1").setIcon(R.drawable.attachment);
代码示例来源:origin: stackoverflow.com
navView = (NavigationView) findViewById(R.id.navView);
Menu m = navView.getMenu();
SubMenu topChannelMenu = m.addSubMenu("Top Channels");
topChannelMenu.add("Foo");
topChannelMenu.add("Bar");
topChannelMenu.add("Baz");
代码示例来源:origin: alexvasilkov/GestureViews
private <T> void addSubMenu(Menu menu, T[] items, T selected, @StringRes int titleId) {
SubMenu sub = menu.addSubMenu(titleId);
sub.setGroupCheckable(Menu.NONE, true, true);
for (int i = 0; i < items.length; i++) {
MenuItem item = sub.add(Menu.NONE, titleId, i, items[i].toString());
item.setCheckable(true);
item.setChecked(items[i] == selected);
}
}
代码示例来源:origin: pockethub/PocketHub
private void setUpNavigationMenu() {
MenuItem organizationContainer = navigationView.getMenu().findItem(R.id.navigation_organizations);
if (organizationContainer.hasSubMenu()) {
SubMenu organizationsMenu = organizationContainer.getSubMenu();
for (int i = 1; i < orgs.size(); i++) {
User organization = orgs.get(i);
if (organizationsMenu.findItem(organization.id().intValue()) == null) {
MenuItem organizationMenuItem = organizationsMenu.add(Menu.NONE, organization.id().intValue(), Menu.NONE, organization.name() != null ? organization.name() : organization.login());
organizationMenuItem.setIcon(R.drawable.ic_github_organization_black_24dp);
//Because of tinting the real image would became a grey block
//avatars.bind(organizationMenuItem, organization);
menuItemOrganizationMap.put(organizationMenuItem, organization);
}
}
} else {
throw new IllegalStateException("Menu item " + organizationContainer + " should have a submenu");
}
}
代码示例来源:origin: wangdan/AisenWeiBo
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu_publish, menu);
// 添加分组
if (AppContext.getAccount().getGroups() == null || AppContext.getAccount().getGroups().getLists().size() == 0) {
}
else {
SubMenu subMenu = menu.addSubMenu(R.id.publish, 333, 2,
GlobalContext.getInstance().getResources().getString(R.string.group_selected_visiable));
for (int i = 0; i < AppContext.getAccount().getGroups().getLists().size(); i++) {
Group group = AppContext.getAccount().getGroups().getLists().get(i);
subMenu.add(100, i, i, group.getName());
}
}
}
代码示例来源:origin: stackoverflow.com
// adding a section and items into it
final SubMenu subMenu = menu.addSubMenu("SubMenu Title");
for (int i = 1; i <= 2; i++) {
subMenu.add("SubMenu Item " + i);
}
代码示例来源:origin: ukanth/afwall
protected void populateMenu(SubMenu sub) {
sub.add(0, MENU_CLEARLOG, 0, R.string.clear_log).setIcon(R.drawable.ic_clearlog);
sub.add(0, MENU_SWITCH_NEW, 0, R.string.switch_new).setIcon(R.drawable.ic_log);
}
代码示例来源:origin: ukanth/afwall
protected void populateMenu(SubMenu sub) {
if (G.enableIPv6()) {
sub.add(0, MENU_IPV6_RULES, 0, R.string.switch_ipv6).setIcon(R.drawable.ic_rules);
sub.add(0, MENU_IPV4_RULES, 0, R.string.switch_ipv4).setIcon(R.drawable.ic_rules);
}
sub.add(0, MENU_FLUSH_RULES, 0, R.string.flush).setIcon(R.drawable.ic_clearlog);
sub.add(0, MENU_SEND_REPORT, 0, R.string.send_report).setIcon(R.drawable.ic_mail);
}
代码示例来源:origin: stackoverflow.com
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_activity_menu, menu);
SubMenu submenu = menu.addSubMenu(0, Menu.FIRST, Menu.NONE, "Preferences");
submenu.add(0, 10, Menu.NONE, "Get Last 5 Packets");
submenu.add(0, 15, Menu.NONE, "Get Last 10 Packets");
submenu.add(0, 20, Menu.NONE, "Get Last 20 Packets");
inflater.inflate(R.menu.main_activity_menu, submenu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case 10:
Toast.makeText(LoginPageActivity.this, "Now "+item.getItemId(), Toast.LENGTH_SHORT).show();
return true;
case 15:
Toast.makeText(LoginPageActivity.this, "Now = "+item.getItemId(), Toast.LENGTH_SHORT).show();
return true;
case 20:
Toast.makeText(LoginPageActivity.this, "Now == "+item.getItemId(), Toast.LENGTH_SHORT).show();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
代码示例来源: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: 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: stackoverflow.com
sMenu.add(0, 4, 0, "SubOption1").setShortcut('5', 'z');
sMenu.add(0, 5, 0, "SubOption2").setShortcut('5', 'z');
代码示例来源:origin: stackoverflow.com
SubMenu fileMenu = menu.addSubMenu("File");
SubMenu editMenu = menu.addSubMenu("Edit");
fileMenu.add(FILE, NEW_MENU_ITEM, 0, "new");
fileMenu.add(FILE, SAVE_MENU_ITEM, 1, "save");
editMenu.add(EDIT, UNDO_MENU_ITEM, 0, "undo");
editMenu.add(EDIT, REDO_MENU_ITEM, 1, "redo");
return super.onCreateOptionsMenu(menu);
代码示例来源:origin: stackoverflow.com
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
final Menu menu = mNavigationView.getMenu();
for (int i = 0; i < 4; i++) {
menu.add("Menu Item " + (i + 1));
}
final SubMenu subMenu = menu.addSubMenu("SubMenu Title");
for (int i = 0; i < 2; i++) {
subMenu.add("SubMenu Item " + (i + 1));
}
for (int i = 0, count = mNavigationView.getChildCount(); i < count; i++) {
final View child = mNavigationView.getChildAt(i);
if (child != null && child instanceof ListView) {
final ListView menuView = (ListView) child;
final HeaderViewListAdapter adapter = (HeaderViewListAdapter) menuView.getAdapter();
final BaseAdapter wrapped = (BaseAdapter) adapter.getWrappedAdapter();
wrapped.notifyDataSetChanged();
}
}
}
代码示例来源:origin: stackoverflow.com
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
SubMenu sub = menu.addSubMenu(0,1,0, "SubMenu");
sub.add(0,11,0,"SubMenu 1");
sub.add(0,12,0,"SubMenu 2");
sub.add(0,13,0,"SubMenu 3");
return true;
}
代码示例来源:origin: stackoverflow.com
@Override
public boolean onCreateOptionsMenu(Menu menu) {
SubMenu fileMenu = menu.addSubMenu("File");
fileMenu.add(FILE, NEW_MENU_ITEM, 0, "new");
...
代码示例来源: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: 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: 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);
}
内容来源于网络,如有侵权,请联系作者删除!