androidkotlinandroid-fragmentsfragment-oncreateview

How to use hasOptionsMenu() in Android?


My code shows an error with the text: "Fragment.hasOptionsMenu can only be called from within the same library group prefix (referenced groupId=androidx.fragment with prefix androidx from groupId=Personal Pocket Dictionary"

I've imported the library and have the right dependency "implementation "androidx.fragment:fragment-ktx:$fragment_version"" so none of that is the issue.

Not sure how to fix this


Solution

  • Use setHasOptionsMenu(true) instead.