Android SubMenu - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android SubMenu class.

This code example shows how to use the following methods: add, getItem
    } 
     
    @SmallTest 
    public void testSubMenu() { 
        final SubMenu subMenu = mMenu.addSubMenu(0, 0, 0, "submenu");
        final MenuItem subMenuItem = subMenu.getItem();
        final MenuItem item1 = subMenu.add(0, 1, 0, "item1");
        final MenuItem item2 = subMenu.add(0, 2, 0, "item2");
         
        // findItem should recurse into submenus 
        Assert.assertEquals(item1, mMenu.findItem(1));
        Assert.assertEquals(item2, mMenu.findItem(2));
    } 
     
    @SmallTest 
    public void testRemove() { 
        final int groupId = 1;
        final MenuItem item1 = mMenu.add(groupId, 1, 0, "item1");
        final MenuItem item2 = mMenu.add(groupId, 2, 0, "item2");
        final MenuItem item3 = mMenu.add(groupId, 3, 0, "item3");
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setHeaderTitle
		return this;
	} 
 
	MenuItemImpl setSubMenu(final SubMenu subMenu) {
		this.subMenu = subMenu;
		this.subMenu.setHeaderTitle(getTitle());
		return this;
	} 
 
	public static MenuItem createItem(final Context context, final int id) {
		return new MenuItemImpl(context).setItemId(id);
	} 
 
} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: add
	@Override 
	public boolean onCreateOptionsMenu(Menu menu) {
		SubMenu file=menu.addSubMenu("Îļþ");
		SubMenu edit=menu.addSubMenu("±à¼­");
		 
		file.add(0,ITEM_NEW_FILE,0,"н¨");
		file.add(0,ITEM_OPEN_FILE,0,"´ò¿ª");
		file.add(0,ITEM_CLOSE,0,"¹Ø±Õ");
		file.add(0,ITEM_SAVE,0,"±£´æ");
		file.add(0,ITEM_SAVE_ALL,0,"±£´æÈ«²¿");
		 
		 
		edit.add(0,ITEM_COPY,0,"¸´ÖÆ");
		edit.add(0,ITEM_CUT,0,"¼ôÇÐ");
		edit.add(0,ITEM_PASTE,0,"Õ³Ìù");
		 
		return true; 
	} 
	 
	@Override 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: add
            menu.setHeaderView(textView);
        } 
         
        menu.add(0, 0, 0, "Test 1");
        SubMenu sm = menu.addSubMenu(0, 0, 0, "Test 1.5 SM");
        sm.add(0, 0, 0, "CM Subitem 1");
        sm.add(0, 0, 0, "CM Subitem 2");
        sm.add(0, 0, 0, "CM Subitem 3");
        menu.add(0, 0, 0, "Test 2");
        menu.add(0, 0, 0, "Test 3");
        menu.add(0, 0, 0, "Test 4");
        menu.add(0, 0, 0, "Test 5");
        menu.add(0, 0, 0, "Test 6");
        menu.add(0, 0, 0, "Test 7");
        menu.add(0, 0, 0, "Test 8");
        menu.add(0, 0, 0, "Test 9");
        menu.add(0, 0, 0, "Test 10");
        menu.add(0, 0, 0, "Test 11");
        menu.add(0, 0, 0, "Test 12");
        menu.add(0, 0, 0, "Test 13");
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: add, setIcon
	public boolean onCreateOptionsMenu(Menu menu) {
		// Menù di gestione modalità di visualizzazione che, per renderle 
		// checkable 
		// le inseriamo in un sottomenu 
		SubMenu mapSubMenu = menu.addSubMenu("Map Modes");
		mapSubMenu.setIcon(android.R.drawable.ic_menu_mapmode);
		int firstItem = Menu.FIRST;
		MenuItem trafficItem = mapSubMenu.add(1, firstItem, firstItem,
				"Traffic"); 
		trafficItem.setCheckable(true);
		trafficItem.setChecked(true);
		MenuItem satelliteItem = mapSubMenu.add(1, firstItem + 1,
				firstItem + 1, "Satellite");
		satelliteItem.setCheckable(true);
		MenuItem streetViewItem = mapSubMenu.add(1, firstItem + 2,
				firstItem + 2, "Street View");
		streetViewItem.setCheckable(true);
		// Visualizziamo il menu 
		return true; 
	} 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android SubMenu Questions & Answers:

See Code Examples for Android SubMenu Methods: