How to use hasOptionsMenu() in Android?

190 Views Asked by At

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

1

There are 1 best solutions below

4
cmak On BEST ANSWER

Use setHasOptionsMenu(true) instead.