0

Does it is possible to Display/Hide the Fragment Option Menu with some condition. I have a fragment from which I add another fragment with some argument.

According to the valid argument condition I have to render Option menu in toolbar.

I tried put some condition in OnCreateOptionMenu but it didn't worked. Any lead will be really helpful.

Krishnakant
  • 1,453
  • 3
  • 18
  • 30
  • hii this can sort out your issue http://stackoverflow.com/questions/10692755/how-do-i-hide-a-menu-item-in-the-actionbar – Awadesh Oct 09 '15 at 18:09

1 Answers1

1

If you are dealing with a fragment use in your onCreate method:

if(condition) {
setHasOptionsMenu(false);
} else {
setHasOptionsMenu(true);
}
Kistamushken
  • 221
  • 3
  • 11