2013-07-18 103 views

回答

0

你必须从DOC覆盖

@Override 
public boolean onOptionsItemSelected(MenuItem item) { 
    switch (item.getItemId()) { 
    case android.R.id.home: 

    } 
    return true;  
} 

:只要选择在选项菜单中的项目

他的勾手被调用。 默认实现只是返回false以使正常的 处理发生(调用项目的Runnable或将消息发送到 视情况而定)。您可以使用这种方法处理 的任何项目,您希望在没有这些其他设施的情况下进行处理。

0

上面的答案工作(谢谢)。但对于我的代码,此解决方案效果最佳...

@Override 
public boolean onOptionsItemSelected(
     com.actionbarsherlock.view.MenuItem item) { 

    item.setOnActionExpandListener(new OnActionExpandListener() { 

     @Override 
     public boolean onMenuItemActionExpand(MenuItem item) { 
          // running changes ... 
      return true; 
     } 

     @Override 
     public boolean onMenuItemActionCollapse(MenuItem item) { 

      // running changes ... 

      return true; 
     } 
    }); 

    return super.onOptionsItemSelected(item); 
}; 
相关问题