没有对onOptionsMenuClosed

没有对onOptionsMenuClosed

本文介绍了没有对onOptionsMenuClosed()的回调.并覆盖onPanelClosed()函数时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有一个使用PreferenceFragment制作的片段,在这里我重写了onOptionsMenuClosed().但是,它的回调没有实现,也没有回调到OnMenuOpened(),OnPanelCosed()...

I have a fragment which is made using PreferenceFragment ,where I am overriding onOptionsMenuClosed(). But , its the callback is not coming to it.Neither is the call back coming to OnMenuOpened(), OnPanelCosed()...

这就是我已经累了.

@Override
public void onOptionsMenuClosed(Menu menu) {
   // TODO Auto-generated method stub
   Log.e(TAG, "close optionmenu");
   super.onOptionsMenuClosed(menu);
}

对于onPanelClosed,这就是我正在尝试的.

and for onPanelClosed this is what i am trying.

@Override
public void onPanelClosed(int featureId, Menu menu) {
    Log.e(TAG,"on panel closed the feature id is vivek "+featureId);
    super.onPanelClosed(featureId, menu);
}

当我对onPanelClosed()执行此操作时,请帮我解决这个问题.

and when i do that for onPanelClosed(),Please help me out with this..

请建议我在哪里弄错了.如果菜单是关闭而没有选择任何选项的话,这是其他任何一种捕获方式.

Please suggest where i am getting it wrong. and is tere any other way to catch if menu is closed without selecting any option.

推荐答案

我终于找到了解决方案:) ..这就是这样做的.

i finally found a solution for this :)..this is what is did.

public boolean isOverflowMenuOpen  = false;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    Activity activity = getActivity();
    activity.getActionBar().addOnMenuVisibilityListener(new OnMenuVisibilityListener() {
    @Override
        public void onMenuVisibilityChanged(boolean isVisible) {
            // TODO Auto-generated method stub
            isOverflowMenuOpen = isOverflowMenuOpen ? false : true;
        }
    });

现在从变量isOverflowMenuOpen中,我可以跟踪溢出菜单是否打开.

now from the variable isOverflowMenuOpen i can track if the overflow menu is open or not.

这篇关于没有对onOptionsMenuClosed()的回调.并覆盖onPanelClosed()函数时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 20:39