fragment - option menu not clicked at first time in sherlockfragment -


i have used option menu in fragment.the problem when go first time fragment ,the option menu click event not called.but when go fragment.and again revist fragment option menu click event called... following code

    //creating option menu     @override     public void oncreateoptionsmenu(menu menu, menuinflater inflater)      {         super.oncreateoptionsmenu(menu, inflater);         inflater.inflate(r.menu.newcarmenu, menu);      }  @override  public boolean onoptionsitemselected(menuitem item) {             //super.onoptionsitemselected(item);                 switch(item.getitemid())    {       case r.id.menunewcar:          _menuclickcallback.onmenuselected();          break;    }    return super.onoptionsitemselected(item);  } 

please tell me why happen?

right now, returning super.onoptionsitemselected(item) every time, selection being passed on. need return true when menuitem has been selected. try instead:

switch(item.getitemid()) {    case r.id.menunewcar:     _menuclickcallback.onmenuselected();     return true;   default:     return super.onoptionsitemselected(item); } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -