https://kotlinlang.org logo
#android
Title
# android
j

juliocbcotta

07/28/2022, 9:36 AM
Could anyone try to help me with this ? https://kotlinlang.slack.com/archives/C09222272/p1658483494439749 I couldn't find an issue on android issue tracker or in the jetbrains issue tracker...
n

Nikolay Puliaev

07/28/2022, 10:58 AM
Never used that, but according to documentation looks like you must cast activity to
MenuHost
Copy code
val menuHost: MenuHost = requireActivity()
  
    // Add menu items without using the Fragment Menu APIs
    // Note how we can tie the MenuProvider to the viewLifecycleOwner
    // and an optional Lifecycle.State (here, RESUMED) to indicate when
    // the menu should be visible
    menuHost.addMenuProvider(object : MenuProvider {
....
}
And use ktx dependency
Copy code
implementation "androidx.activity:activity-ktx:$activity_version"
j

juliocbcotta

07/28/2022, 12:08 PM
I will try casting it, but it is just odd as the code compiles and runs. Just the IDE that is broken.
9 Views