Reputation: 35
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.
Upvotes: 1
Views: 4220
Reputation: 486
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.
Upvotes: 0