public void clickOnMenuItem(String text, boolean subMenu)
	{
		sleeper.sleepMini();

		TextView textMore = null;
		int [] xy = new int[2];
		int x = 0;
		int y = 0;

		if(!dialogUtils.waitForDialogToOpen(MINI_WAIT, false)) {
			try{
				sender.sendKeyCode(KeyEvent.KEYCODE_MENU);
				dialogUtils.waitForDialogToOpen(WAIT_TIME, true);
			}catch(SecurityException e){
				Assert.fail("Can not open the menu!");
			}
		}
		boolean textShown = waiter.waitForText(text, 1, WAIT_TIME, true) != null;

		if(subMenu && (viewFetcher.getCurrentViews(TextView.class, true).size() > 5) && !textShown){
			for(TextView textView : viewFetcher.getCurrentViews(TextView.class, true)){
				x = xy[0];
				y = xy[1];
				textView.getLocationOnScreen(xy);

				if(xy[0] > x || xy[1] > y)
					textMore = textView;
			}
		}
		if(textMore != null)
			clickOnScreen(textMore);

		clickOnText(text, false, 1, true, 0);
	}
public void clickOnMenuItem ( String text , boolean subMenu ) { sleeper . sleepMini ( ) ; TextView textMore = null ; int [ ] xy = new int [ 2 ] ; int x = 0 ; int y = 0 ; if ( ! dialogUtils . waitForDialogToOpen ( MINI_WAIT , false ) ) { try { sender . sendKeyCode ( KeyEvent . KEYCODE_MENU ) ; dialogUtils . waitForDialogToOpen ( WAIT_TIME , true ) ; } catch ( SecurityException e ) { Assert . fail ( "Can not open the menu!" ) ; } } boolean textShown = waiter . waitForText ( text , 1 , WAIT_TIME , true ) != null ; if ( subMenu && ( viewFetcher . getCurrentViews ( TextView . class , true ) . size ( ) > 5 ) && ! textShown ) { for ( TextView textView : viewFetcher . getCurrentViews ( TextView . class , true ) ) { x = xy [ 0 ] ; y = xy [ 1 ] ; textView . getLocationOnScreen ( xy ) ; if ( xy [ 0 ] > x || xy [ 1 ] > y ) textMore = textView ; } } if ( textMore != null ) clickOnScreen ( textMore ) ; clickOnText ( text , false , 1 , true , 0 ) ; }
Clicks on a menu item with a given text.

@param text the menu text that should be clicked on. The parameter <strong>will</strong> be interpreted as a regular expression.
@param subMenu true if the menu item could be located in a sub menu