android - Why Is ActionBarSherlock Menu Not Working? -


im noob android development , i'm having issue making menu item listener work. when click on menu item toast supposed display nothing happens. have correct imports , have implemented menuitem listener don't understand why not working. appreciated.

//abs menuitem import import com.actionbarsherlock.view.menuitem.onmenuitemclicklistener;  @override public boolean oncreateoptionsmenu(menu menu) {      menu.add(0,1,0,"gender").seticon(r.drawable.female_icon).setonmenuitemclicklistener(this).setshowasaction(menuitem.show_as_action_always);     menu.add(0,2,0,"flip").seticon(r.drawable.flip_icon).setonmenuitemclicklistener(this).setshowasaction(menuitem.show_as_action_always);     menu.add(0,3,0,"preferences").seticon(r.drawable.ic_action_example).setonmenuitemclicklistener(remedyactivity.this).setshowasaction(menuitem.show_as_action_always);     menu.add(0,4,0,"help").seticon(r.drawable.info).setonmenuitemclicklistener(remedyactivity.this).setshowasaction(menuitem.show_as_action_always);       //side navigation     getsupportmenuinflater().inflate(r.menu.main_menu, menu);     if (sidenavigationview.getmode() == mode.right) {         menu.finditem(r.id.mode_right).setchecked(true);     } else {         menu.finditem(r.id.mode_left).setchecked(true);     }     return super.oncreateoptionsmenu(menu); }  @override public boolean onmenuitemclick(menuitem item) {     // todo auto-generated method stub     switch (item.getitemid())     {         case 1:                toast mtoast = toast.maketext(remedyactivity.this, "works", toast.length_short);             return true;            case 2:                toast mtoast2 = toast.maketext(remedyactivity.this, "works", toast.length_short);             return true;     }     return false; } 

edit

@override public boolean onoptionsitemselected(menuitem item) {     switch (item.getitemid()) {         case android.r.id.home:             sidenavigationview.togglemenu();             break;         case r.id.mode_left:             item.setchecked(true);             sidenavigationview.setmode(mode.left);             break;         case r.id.mode_right:             item.setchecked(true);             sidenavigationview.setmode(mode.right);             break;         case 1:   // id xml file             toast mtoast = toast.maketext(remedyactivity.this, "works", toast.length_short);             break;   // handled click, dont pass chain          case 2:   // id xml file             toast mtoast2 = toast.maketext(remedyactivity.this, "works", toast.length_short);             break;          default:             return super.onoptionsitemselected(item);     }     return true; } 

i noticed trying show toast, while using side navigation. i've had issues trying show toast library in past. try method determine whether or not button working such nslog.


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -