menu won't show up android -
hi i'm trying show menu when user presses menu button. i'm using code documentation options menu won't show up. guess should have listener menu button, how?? class far:
public class appmenu extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.about); } @override public boolean oncreateoptionsmenu(menu menu) { menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.appmenu, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle item selection switch (item.getitemid()) { case r.id.hello: sayhello(); return true; case r.id.bye: finish(); return true; default: return super.onoptionsitemselected(item); } } } here xml file
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/hello" android:title="hello" android:icon="@drawable/icon"/> <item android:id="@+id/bye" android:title="bye" /> </menu> thanks !
this answer in response comment discussion on question.
you can't have menu appear outside of activity. means have start activity , inside activity you'll able menu appear on menu button press.
Comments
Post a Comment