Hi Folks, I have been working working with Eclipse, the Android plug-in and the 1.1 SDK. So far I quite like it and its bringing back memories of the BeOS's API :) I generally learn by doing, and I am stuck with some menu problems. I want to create my menus using and XML file, and I can do that, but I can't work out how to link up my menu values and the XML values for my case statements.
I have the following XML file, res/menu/options_menu.xml: <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/options_menu_settings" android:title="Settings" /> <item android:id="@+id/options_menu_about" android:title="About" /> <item android:id="@+id/options_menu_quit" android:title="Quit" /> </menu> Creating the menu by inflating it using the following: public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.options_menu, menu); return true; } So far this works and draws the menu. I have the following file res/values/strings.xml: <?xml version="1.0" encoding="utf-8"?> <resources> <item name="options_menu_quit" type="id" format="integer">0</item> </resources> But how do I get the case statement and the XML to fit? I would have expected it to be something like this: /* Handles item selections */ public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case options_menu_quit: finish(); return true; } return false; } But that doesn't work as the options_menu_quit can't be resolved. My other question is about menu icons. I get that this code adds an icon to the menu: menu.add(0, MENU_QUIT, 0, "Quit") .setIcon(R.drawable.menu_quit_icon); But if I am drawing a menu by inflating XML, how do I specify an icon there? -- Thanks, Andy McCall -- Email: [email protected] GTalk: [email protected] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---

