I have an app, which have toggle button in action menu item, though i\'m using Actionbar Sherlock, I don\'t know, how to place the toggle button in the action menu item. I don\'
Other approach would be to use a custom layout for your ActionBar:
Basically you define a layout that contains your Toggle:
ALTERNATIVE 1: Then in your Activity or Fragment container you do:
ActionBar actionBar = getSupportActionBar();
actionBar.setCustomView(R.layout.actionbar_top);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM);
...
ToggleButton button = (ToggleButton) findViewById(R.id.actionbar_service_toggle);
Notice that you are having a real ToggleButton and you are handling it in code as a real object ToggleButton, which has lots of advantages compared to having you re-implement your own toggle (theme, reliability, views hierarchy, native support...).
Source code here.
ALTERNATIVE 2: Another way to do it is embed your custom view into a regular menu view: