Example usage for android.app Fragment performCreateOptionsMenu

List of usage examples for android.app Fragment performCreateOptionsMenu

Introduction

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

Prototype

boolean performCreateOptionsMenu(Menu menu, MenuInflater inflater) 

Source Link

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  ww  . j  a  v  a2 s  . c o  m
                    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;
}