0

Two days ago, I switched switched from xamarin to android studio and I'm extremly new to Java. I'm trying to create a DrawerLayout with a NavigationView but once I try to override onOptionsItemSelected it simply don't wanna come. So what should I do? I tried to paste a method, but android studio treats it as a normal variable or method.

Edit : Solved.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Tamim Attafi
  • 2,253
  • 2
  • 17
  • 34

2 Answers2

0

onCreateOptionsMenu() is a method like onCreate(). You have to write this method in the same level of your onCreate() and not inside. To do this, move onCreateOptionsMenu() below the very next closing brace.

François Legrand
  • 1,151
  • 1
  • 14
  • 25
0

onCreateOptionMenu() is same as onCreate() method, you have to write down this method below one more "curly braces".

It solve your problem.

Ankit Patidar
  • 2,731
  • 1
  • 14
  • 22