1. Are you ready for the Galaxy S20? Here is everything we know so far!

Need help with menu option.

Discussion in 'Android Apps & Games' started by arash.moeen, May 22, 2011.

  1. arash.moeen

    arash.moeen Lurker
    Thread Starter

    I'm trying to make a simple menu in my program but I've suffering from a problem which prevented my program to run.

    here is my code:

    Code (Text):
    1. package de.vogella.android.menuitem;
    2.  
    3. import android.app.Activity;
    4. import android.os.Bundle;
    5. import android.view.Menu;
    6. import android.view.MenuInflater;
    7.  
    8.  
    9.  
    10.  
    11.  
    12.  
    13. public class MainActivity extends Activity {
    14.     /** Called when the activity is first created. */
    15.     @Override
    16.     public void onCreate(Bundle savedInstanceState) {
    17.         super.onCreate(savedInstanceState);
    18.         setContentView(R.layout.main);
    19.     }
    20.    
    21.     @Override
    22.     public boolean onCreateOptionsMenu(Menu menu) {
    23.         super.onCreateOptionsMenu(menu);
    24.         MenuInflater inflater = getMenuInflater();
    25.         inflater.inflate(R.menu.game_menu, menu);
    26.         return true;
    27.     }
    28. }
    the error is at this line :

    Code (Text):
    1. inflater.inflate(R.[B]menu[/B].game_menu, menu);
    it says menu cannot be resolved or it's not a field.

    can you guys please help me ? thnx in advance.
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...

Share This Page

Loading...