Example usage for android.app Fragment onDestroyOptionsMenu

List of usage examples for android.app Fragment onDestroyOptionsMenu

Introduction

In this page you can find the example usage for android.app Fragment onDestroyOptionsMenu.

Prototype

public void onDestroyOptionsMenu() 

Source Link

Document

Called when this fragment's option menu items are no longer being included in the overall options menu.

Usage

From source file:android.app.FragmentManager.java

public boolean dispatchCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    boolean show = false;
    ArrayList<Fragment> newMenus = null;
    if (mAdded != null) {
        for (int i = 0; i < mAdded.size(); i++) {
            Fragment f = mAdded.get(i);
            if (f != null) {
                if (f.performCreateOptionsMenu(menu, inflater)) {
                    show = true;/*w w w.j a  va2 s . c om*/
                    if (newMenus == null) {
                        newMenus = new ArrayList<Fragment>();
                    }
                    newMenus.add(f);
                }
            }
        }
    }

    if (mCreatedMenus != null) {
        for (int i = 0; i < mCreatedMenus.size(); i++) {
            Fragment f = mCreatedMenus.get(i);
            if (newMenus == null || !newMenus.contains(f)) {
                f.onDestroyOptionsMenu();
            }
        }
    }

    mCreatedMenus = newMenus;

    return show;
}