And you are going to have the same problem for MENU_QUIT as well. public class HelloAndroid extends Activity { private static final int MENU_NEW_GAME = 0; private static final int MENU_QUIT = 1;
//.... other stuff for the class } ---------------------------------------------------------------------- There are only 10 types of people in the world... Those who know binary and those who don't. ---------------------------------------------------------------------- On Tue, Apr 27, 2010 at 11:42 AM, Justin Anderson <janderson....@gmail.com>wrote: > you haven't declared MENU_NEW_GAME to be anything... > > > public class HelloAndroid extends Activity > { > private static final int MENU_NEW_GAME = 0; > > //.... other stuff for the class > } > > ---------------------------------------------------------------------- > There are only 10 types of people in the world... > Those who know binary and those who don't. > ---------------------------------------------------------------------- > > > > On Tue, Apr 27, 2010 at 11:17 AM, amitait <amit...@gmail.com> wrote: > >> Hi all. >> >> I'm doing my first steps with developing for the Android and I'm >> already stuck. >> >> I had this code: >> package com.example.helloandroid; >> >> import android.app.Activity; >> import android.os.Bundle; >> >> public class HelloAndroid extends Activity { >> /** Called when the activity is first created. */ >> @Override >> >> public void onCreate(Bundle savedInstanceState) { >> super.onCreate(savedInstanceState); >> setContentView(R.layout.main);}} >> >> It worked fine. >> >> So I tried to play with menus and added a piss of code: >> >> package com.example.helloandroid; >> >> import android.app.Activity; >> import android.os.Bundle; >> import android.view.Menu; >> import android.view.MenuItem; >> >> public class HelloAndroid extends Activity { >> /** Called when the activity is first created. */ >> @Override >> >> public void onCreate(Bundle savedInstanceState) { >> super.onCreate(savedInstanceState); >> setContentView(R.layout.main); >> } >> >> /* Creates the menu items */ >> public boolean onCreateOptionsMenu(Menu menu) { >> menu.add(0, MENU_NEW_GAME, 0, "New Game"); >> //menu.add(0, MENU_QUIT, 0, "Quit"); >> return true; >> } >> >> /* Handles item selections */ >> public boolean onOptionsItemSelected(MenuItem item) { >> switch (item.getItemId()) { >> case MENU_NEW_GAME: >> //newGame(); >> return true; >> /*case MENU_QUIT: >> quit(); >> return true;*/ >> } >> return false; >> } >> >> } >> >> >> So now I get MENU_NEW_GAME cannot be resolved (eclipse) for this line: >> menu.add(0, MENU_NEW_GAME, 0, "New Game"); >> >> What am I doing wrong? >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Beginners" group. >> >> NEW! Try asking and tagging your question on Stack Overflow at >> http://stackoverflow.com/questions/tagged/android >> >> To unsubscribe from this group, send email to >> android-beginners+unsubscr...@googlegroups.com<android-beginners%2bunsubscr...@googlegroups.com> >> For more options, visit this group at >> http://groups.google.com/group/android-beginners?hl=en >> > > -- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en