0

I have some Kotlin code that is attempting to tweak the visibility of some option menu items inside a fragment using onCreateMenuOptions. Kotlin is complaining about an accidential override, and there being dual onCreateMenuOption declarations in the code.

Nothing I am doing explicitly is doing this, so I'm guessing this is something Kotlin is generating in the background, akin to the getters created on object constructors, but I'm at a loss what is triggering this, nor how to fix it. An onCreateOptionsMenu declaration from within an activity works fine (but does have a different signature). I just tried dropping an onCreateOptionsMenu declaration into another independent fragment, and got the same result.

Any clues or ideas what is causing this, or how to determine exactly what Kotlin is generating behind the scenes?

Thanks and regards - Andrew

  • as a followup just tried onPrepareOptionsMenu in the same context, and this works fine. So I'm pretty sure I can work around my immediate problem using onPrepare, but still curious what is happening with the onCreate
  • 2
    Please include your code that reproduces the issue. – ianhanniballake Apr 02 '21 at 05:26
  • As from the comment to Adrian below, I've been putting some effort into understanding the new navigation model, so am not going to put any major effort into resolving this specific problem. I did have a look at reducing this to a simple example that exhibited the problem, but nothing seems to be failing now! I'm guessing that something was out of sync in the IDE. Who knows? – Andrew McLaren Apr 10 '21 at 03:20

1 Answers1

0

https://developer.android.com/codelabs/android-navigation#8

you use jetpack navigation here is link where you know how to use it,it is much better than other

Adnan haider
  • 553
  • 8
  • 21
  • Thanks for that prod! Its something I should have done a while ago, but I only touch Android as a peripheral activity, and it seems that everytime I do, the framework has added a lot more richness, and also deprecated many of the older ways of doing things! I've been working though the tutorial, and have committed to move the (not that complex) app away from the older navigation model to the new. That of course has raised some new questions, but I'll post them in a separate note. – Andrew McLaren Apr 10 '21 at 03:16