Code example for MenuItem

Methods: isVisiblesetVisible

0
    public void testVisibility() { 
        final MenuItem item1 = mMenu.add(0, 1, 0, "item1");
        final MenuItem item2 = mMenu.add(0, 2, 0, "item2");
         
        // Should start as visible 
        Assert.assertTrue("Item did not start as visible", item1.isVisible());
        Assert.assertTrue("Item did not start as visible", item2.isVisible());
 
        // Hide 
        item1.setVisible(false);
        Assert.assertFalse("Item did not become invisible", item1.isVisible());
        mMenu.findItem(2).setVisible(false);
        Assert.assertFalse("Item did not become invisible", item2.isVisible());
    } 
     
    @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");
Connect your IDE to all the code out there  Get Codota for Java