Code example for PopupMenu

Methods: setOnMenuItemClickListener

0
	PopupMenuWrapper(Activity activity, View view) {
		menu = new PopupMenu(activity, view);
	} 
	 
	public void setOnMenuItemClickListener(final PopupMenuWrapper.OnMenuItemClickListener listener) {
		menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
			@Override 
			public boolean onMenuItemClick(MenuItem item) {
				listener.onMenuItemClick(item);
				return false; 
			} 
		}); 
	} 
	 
	public void inflate(int menuId) {
		// done without using the PopupMenu.inflate() method, which isn't available on Honeycomb. 
		// this method works on both Honeycomb and Ice Cream Sandwich. 
		MenuInflater inflater = menu.getMenuInflater();
		Menu baseMenu = menu.getMenu();
		inflater.inflate(menuId, baseMenu);
	}