To add onClickListener
to a view in your action bar
you have to create a reference to that view
first and then in the onCreateOptionsMenu()
method you can register the onClickListener
.
See the answer to this question herehere. Its the same principle, you're simply using a 'star icon' instead of a switch.