java - Android: onOptionsItemSelected() called in SherlockActivity, but not in SherlockFragmentActivity -


i have problems onoptionsitemselected() in sherlockfragmentactivity. oncreateoptionsmenu() called , option menu built perfectly, when click on options item, onoptionsitemselected() isn't called.

i tried same following code in test project using sherlockactivity , there works:

    @override     public boolean oncreateoptionsmenu(menu menu) {      menu.add(0, 1, 0, "hi").setshowasaction(menuitem.show_as_action_if_room | menuitem.show_as_action_with_text);     menu.add(0, 1, 0, "ha").setshowasaction(menuitem.show_as_action_never | menuitem.show_as_action_never);      return true;     }      @override     public boolean onoptionsitemselected(menuitem item) {         if (item.getitemid() == 1) {             // someting!          }         return true;     } 

in both cases, following imports done:

   import com.actionbarsherlock.app.actionbar;    import com.actionbarsherlock.view.menu;    import com.actionbarsherlock.view.menuitem; 

does know help? thank you!

i think happens because don't set menuitemclicklistener (you create items in code). if define menu xml android set listener , fire onoptionsitemselected on click.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -