I have added one star icon on Action Bar. Now I want to add click event on that star. If the star is clicked then it should be bright or Turned ON which is OFF by default. And if that star is ON and clicked, then it should go to OFF. I am not getting any idea how to perform onClick event on action bar.
2 Answers
2
-
done these all but in my action bar, I have star image icon where I want to perform onClick operation. Commented Aug 22, 2014 at 8:50
-
1this doesn't anwer the question, it's only a link to action bar official documentation. Commented Oct 23, 2019 at 14:29
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 here. Its the same principle, you're simply using a 'star icon' instead of a switch.