1

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.

1
  • how did you add the start to the actionbar?
    – Blackbelt
    Commented Aug 22, 2014 at 8:33

2 Answers 2

3

You have a good example here.

Action Bar Example

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
  • 1
    this doesn't anwer the question, it's only a link to action bar official documentation. Commented Oct 23, 2019 at 14:29
0

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.