Code example for Menu

Methods: clear

0
	public boolean onPrepareOptionsMenu(Menu menu)
	{ 
		super.onPrepareOptionsMenu(menu);
 
		// Remove all the items from the menu. 
		menu.clear();
 
		// Get the focused screen widget. 
		ScreenWidget currentScreen = mMoSyncThread.getCurrentScreen();
		if ( currentScreen != null )
		{ 
			// Get the menu items for that screen. 
			List<OptionsMenuItem> items = currentScreen.getMenuItems();
			// Add each menu item to the options menu. 
			for (int i=0; i < items.size(); i++)
			{ 
				MenuItem item = menu.add ( 0, items.get(i).getId(), 0, items.get(i).getTitle() );
				if ( items.get(i).hasIconFromResources() )
				{ 
					item.setIcon( items.get(i).getIconResId() );
				}