1

I have some questions regarding android action bar and tab fragments. I have 3 fragments and whenever the third fragment is selected, then I will show the menu item on the actiobar.

how should i go about it?

I tried referencing to the button at runtime and set the visibility to true, but it seems to be null.

0

1 Answer 1

1

You should look into the Fragment method setHasOptionsMenu(boolean hasMenu). This way each Fragment can manage its own menu items and the system will take care of the hiding/showing of the action items based on this value. In your case it would seem you would set this to false for your first and second fragments, while the third would pass a true so it hits the onCreateOptionsMenu method.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.