You have two problems: one setShowAsAction returns void , so you cannot associate it with another call.
Secondly, MenuItem does not have a setID method. You cannot change the identifier after creating the item. To set the identifier, you must do this in the [ add ] method of Menu 2 ,
menu.add("new", myItemId, myOrder, "TEXT" ) .setIcon(R.drawable.icon_1, ) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
source share