Code example for Fragment

Methods: getChildFragmentManageronCreatesetHasOptionsMenu

0
    public static class Menu2Fragment extends Fragment {
        Menu3Fragment mFragment3;
 
        @Override 
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setHasOptionsMenu(true);
 
            FragmentManager fm = getChildFragmentManager();
            FragmentTransaction ft = fm.beginTransaction();
            mFragment3 = (Menu3Fragment)fm.findFragmentByTag("f3");
            if (mFragment3 == null) {
                mFragment3 = new Menu3Fragment();
                ft.add(mFragment3, "f3");
            } 
            ft.commit();
        } 
 
        @Override 
        public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
Stop searching for code, let great code find you!  Add Codota to your java IDE