Search code examples
androidfragmentoptionmenu

Can I call setHasOptionsMenu() from Fragment Constructor?


Calling setHasOptionsMenu(true) from constructor, which is obviously called even before onCreate(), works perfectly! Can I do that? What will be problems?


Solution

  • Yes, you can call setHasOptionsMenu(true) from the constructor.