Gopikrishna S Gopikrishna S - 1 year ago 66
Android Question

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?

Answer Source

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