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");
6
CodeRank
Experience pair programming with AI  Get Codota for Java
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);
	} 
 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
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 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
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");
6
CodeRank
Experience pair programming with AI  Get Codota for Java
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; 
	} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:add
        this.view = view;
    } 
 
    boolean createOptionsMenu(Menu menu) {
        SubMenu settingMenu = menu.addSubMenu("Settings");
        settingMenu.add(0, MENU_SETTINGS_CYCLES, 0, "Cycles");
        settingMenu.add(0, MENU_SETTINGS_FRAMESKIP, 0, "Frameskip");
        settingMenu.add(0, MENU_SETTINGS_MEMORY_SIZE, 0, "Memory Size");
        settingMenu.add(0, MENU_SETTINGS_SOAP_VIDEO, 0, "Soap Video")
                .setCheckable(true).setChecked(soapVideo);
        settingMenu.add(0, MENU_SETTINGS_AUDIO_ENABLED, 0, "Audio Enabled")
                .setCheckable(true).setChecked(audioEnabled);
        menu.add(0, MENU_KEYBOARD, 0, "Keyboard");
        menu.add(0, MENU_QUIT, 0, "Quit");
        return true; 
    } 
 
    boolean prepareOptionsMenu(Menu menu) {
        menu.findItem(MENU_SETTINGS_SOAP_VIDEO).setChecked(soapVideo);
        menu.findItem(MENU_SETTINGS_AUDIO_ENABLED).setChecked(audioEnabled);
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:add, setGroupCheckable
     
    @Override 
    public boolean onCreateOptionsMenu(Menu menu) {
               
        SubMenu subMenuFile = menu.addSubMenu("Color");
        subMenuFile.add(COLOR_MENU_GROUP, RED, Menu.NONE, "Red");
        subMenuFile.add(COLOR_MENU_GROUP, GREEN, Menu.NONE, "Green");
        subMenuFile.add(COLOR_MENU_GROUP, BLUE, Menu.NONE, "Blue");
        subMenuFile.setGroupCheckable(COLOR_MENU_GROUP, true, false);
         
        SubMenu subMenuEdit = menu.addSubMenu("Font Style");
        subMenuEdit.add(FONT_MENU_GROUP, REGULAR, Menu.NONE, "Regular")
            .setChecked(true);
        subMenuEdit.add(FONT_MENU_GROUP, BOLD, Menu.NONE, "Bold");
        subMenuEdit.add(FONT_MENU_GROUP, ITALIC, Menu.NONE, "Italic");
        subMenuEdit.setGroupCheckable(FONT_MENU_GROUP, true, true);
         
        menu.add(Menu.NONE, HELP, Menu.NONE, "Help");
         
        return super.onCreateOptionsMenu(menu);
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:add
        this.view = view;
    } 
 
    boolean createOptionsMenu(Menu menu) {
        SubMenu settingMenu = menu.addSubMenu("Settings");
        settingMenu.add(0, MENU_SETTINGS_CYCLES, 0, "Cycles");
        settingMenu.add(0, MENU_SETTINGS_FRAMESKIP, 0, "Frameskip");
        settingMenu.add(0, MENU_SETTINGS_MEMORY_SIZE, 0, "Memory Size");
        settingMenu.add(0, MENU_SETTINGS_SOAP_VIDEO, 0, "Soap Video")
                .setCheckable(true).setChecked(soapVideo);
        settingMenu.add(0, MENU_SETTINGS_AUDIO_ENABLED, 0, "Audio Enabled")
                .setCheckable(true).setChecked(audioEnabled);
        menu.add(0, MENU_KEYBOARD, 0, "Keyboard");
        menu.add(0, MENU_QUIT, 0, "Quit");
        return true; 
    } 
 
    boolean prepareOptionsMenu(Menu menu) {
        menu.findItem(MENU_SETTINGS_SOAP_VIDEO).setChecked(soapVideo);
        menu.findItem(MENU_SETTINGS_AUDIO_ENABLED).setChecked(audioEnabled);
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:add, setIcon
	@Override 
	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; 
	} 
 
	@Override 
	public boolean onOptionsItemSelected(MenuItem item) {
6
CodeRank
Experience pair programming with AI  Get Codota for Java
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");
5
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android SubMenu Questions & Answers:

See Code Examples for Android SubMenu Methods: