Android menu will not appear when the menu button is pressed in AVD -
i have defined menu laid out http://developer.android.com/guide/topics/ui/menus.html
here menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/menu_home" android:icon="@drawable/ic_menu_home" android:title="main menu" /> <item android:id="@+id/menu_signout" android:icon="@drawable/ic_menu_signout" android:title="sign out" /> </menu>
and code, placed in activity
@override public boolean oncreateoptionsmenu(menu menu) { menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.menu, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle item selection switch (item.getitemid()) { case r.id.menu_home: startactivity(new intent(manageusersactivity.this, mainmenuactivity.class)); finish(); return true; case r.id.menu_signout: //todo: issue signout clear cookie finish(); return true; default: return super.onoptionsitemselected(item); } }
unfortunately, when click menu button, nothing happens.
try chaining superclass in oncreateoptionsmenu()
. here sample project demonstrating use of menuinflater
options , context menus.
Comments
Post a Comment